-
-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the Knp menu for the back end header menu #860
Conversation
e105d57
to
d13e3ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep the back end menu naming as-is, meaning the be_menu.twig
and the respective event. And use a new template and a new event name for the be_header_menu
, as devs listening to the BACKEND_MENU_BUILD
event are for sure not checking the root node name atm.
I guess you are right, although it is ugly to have two different events for basically the same thing in the same context. But changed in d0b9a00 now. |
I am still not convinced that using two events is the right thing to do. Also, I doubt that it would cause any problems, because extensions listening to the $categoryNode = $event->getTree()->getChild('system');
if (null === $categoryNode) {
return;
} And since there is no intersection of child nodes, this should never cause any problems: Main menu
Header menu
@contao/developers What do you think? Can we use the same event for both menus? |
If I can differentiate between header and main navigation easily (like |
I'm with @ausi except for the fact that I would like to compare to a class constant rather than a regular string. |
Exactly like this. But in Yoda style. 😂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in the config.php
files across all bundles are also not related to this PR at all. Maybe you can create a separate one (according to what we just discussed yesterday) to change that across all bundles. I'm not sure about the implications, but we should discuss that in the separate PR.
Of course they are related to this PR. The PR reworks the back end menus and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat work here! Well done! I have my concerns regarding BC breaks and added them as comments so we can discuss. Otherwise this PR is in a good shape 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As stated in inline comments, this currently introduces unnessary BC breaks which could be nicely solved using separate listeners for the menu items, just like it's done e.g. for the debug link in the manager-bundle.
The menu builder does not build these URLs – the injected generators do.
I disagree. The manager bundle uses an event listener, because that is the only way for other bundles to add menu links. There is no point in using separate event listeners except for keeping the constructor arguments the way they are now. Other than that, it is just more complicated and more confusing for anyone who needs to work with it. |
I kinda agree with @Toflar. The builder is responsible for providing an event to build the menu, not to actually build the menu. That's what the event listeners are for. If the core menu items are not added by an event listener, I can't use priorities to be before/after that listener. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still standing by my statement (this is to shut up PR reminders 😂 )
I have extracted the main menu changes into a separate PR: #1101 |
6f22506
to
3bfc077
Compare
The PR has been rebased and changed according to what we have discussed. Please review again. 😊 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So much cleaner now, with proper responsibilities! I like this 😄 👍
Should have more than one PR approval here before merge though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. I think there's one optimization possible:
Same as the debug button, the preview and logout button should be added in their own menu listener. These service listener should contain the code from PreviewUrlGenerator
and LogoutUrlGenerator
, because the url generators don't make much sense to me. They're never being reused, they are solely for the purpose of generating that button. It would also make DI for the regular menu builder much simpler, because it wouldn't contain multiple services only needed for one button each.
|
||
$buger = $factory | ||
->createItem('burger') | ||
->setLabel('<button type="button" id="burger"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 12h18M3 6h18M3 18h18"/></svg></button>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The button should have a label or title, so we should probably not remove MSC.burgerTitle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, because the button is only visible on mobile devices and neither title nor label would be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would assume it is visible to screen readers, and most likely to an iPhone screen reader as well
The services do not generate the buttons but only their URLs. This means whenever you want to generate the logout URL or the preview URL, you can use the service. As soon as #989 is merged, we can reuse the preview URL service in the |
No you cannot. The service is explicitly bound to the |
58678f0
to
f4dff99
Compare
I have implemented the requested changes. Please review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good now to me! Just a few minor notes 👍
This PR makes the necessary changes so the back end header menu is built via Knp menu and the debug button can be added in the manager bundle (this was an open TODO).
The PR also "fixes" the back end main menu, which does not adhere to the Knp menu standards and thus is only partially extendable.
TODOs