Closed jamesmacwhite closed 3 years ago
Happy to accommodate your needs. Migrating from a Craft 2 to 3 site can be tricky in a number of ways (not just for CP Nav), so the recommended approach would actually be to reset the layouts for peace-of-mind.
If you want to add a PR, happy to accept it, or I can add this in the next release.
@engram-design Thank you! That is most helpful. I have made a PR and referenced this issue in the comments.
Resolved by #86.
Added in 3.0.15
Description
I've found from a Craft 2 site the CP nav layouts become messed up like icons being repeated everywhere and items missing. Using the reset layout action resolves this, however I was looking at doing this in a content migration to automate it.
I can't call the controller directly as it's intended to use POST and this is from console, but I was able to use the similar code within the
NavigationController.php
with theCpNav::$plugin
calls to replicate the delete layout and reset logic in a content migration. However, when calling from a migration, things break when hitting this line:https://github.com/verbb/cp-nav/blob/craft-3/src/services/Service.php#L192
This is because it's assumed it's a web request, but calling from console, this isn't the case. There is a potentially simple solution, wrap it with:
Would you consider allowing this change? I'm aware this is a very specific requirement but in theory shouldn't hurt the existing purpose. Maybe there is a fixable reason why CP layouts are messed up, but resetting them does seem to resolve it, so I figured that should be the solution.