-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
[RFC] Use KnpMenu for the main backend menu #1066
Conversation
src/Event/BackendMenuEvent.php
Outdated
| use Knp\Menu\ItemInterface; | ||
| use Symfony\Component\EventDispatcher\Event; | ||
|
|
||
| class BackendMenuEvent extends Event |
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.
can or should we have a universal menu event? Or does such an event class maybe already exist in KnpMenu?
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.
Or does such an event class maybe already exist in KnpMenu?
I don't find any such events in either KnpMenu and KnpMenuBundle.
can or should we have a universal menu event?
We probably could. I can't think of any reasons or possibilities for having more than the tree in this event.
| @@ -0,0 +1,65 @@ | |||
| <?php | |||
|
|
|||
| namespace Contao\CoreBundle\EventListener\BackendMenu; | |||
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.
Are we really using subnamespaces for event listeners?
|
|
||
| public function onBuild(BackendMenuEvent $event) | ||
| { | ||
| $tree = $event->getTree(); |
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.
This could be moved after the if-null condition
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.
Correct, we don't need to return the tree.
| $tree->addChild($node); | ||
| } | ||
|
|
||
| // Create the child nodes |
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 prefer to refactor this to a method that generates the child.
src/Resources/config/listener.yml
Outdated
| @@ -40,6 +40,14 @@ services: | |||
| tags: | |||
| - { name: kernel.event_listener, event: kernel.terminate, method: onKernelTerminate } | |||
|
|
|||
| contao.listener.backend_menu.legacy_menu_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.
same here with the namespace
src/Event/MenuEvent.php
Outdated
| { | ||
| private $tree; | ||
|
|
||
| public function __construct(ItemInterface $tree) |
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 event should also contain the menu factory, so it does not need to be injected into the listener.
src/Menu/BackendMenuRenderer.php
Outdated
| public function render(ItemInterface $item, array $options = []) | ||
| { | ||
| $lang = [ | ||
| 'skipNavigation' => \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']) |
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.
This can later be solved with #1072
src/Resources/config/services.yml
Outdated
| factory: ["@contao.menu.backend_menu_builder", create] | ||
| arguments: ["@request_stack"] | ||
| tags: | ||
| - { name: knp_menu.menu, alias: backend } |
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.
Not sure if we need this tag, but if then the alias is not useful.
src/Resources/config/services.yml
Outdated
| - "@knp_menu.factory" | ||
| - "@event_dispatcher" | ||
|
|
||
| contao.menu.backend_menu: |
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.
According to discussion with @sheeep we don't need the menu as a service because of a custom renderer.
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.
but we should wait for #1072
ed0a7e5
to
3dadd44
Compare
ea20469
to
fddab6f
Compare
f8d0538
to
4c3e44a
Compare
|
I'm done fixing the coding style and switching to the translator. There are, however, there is an issue that needs to be addressed in the OLD <li class="tl_level_1_group […] AjaxRequest.toggleNavigation( […] '<?= $arrModules['ajaxUrl']; ?> […]NEW <li class="tl_level_1_group […] AjaxRequest.toggleNavigation( […] '{{ path('contao_backend') }} […]Do we no longer need the |
96ab909
to
486fea4
Compare
486fea4
to
8cdb072
Compare
|
Never mind, I just realized that the |
|
Thanks a lot @sheeep. |
This PR refactors the way the backend menu is created.
hasAccesson backend modulesContao\BackendUsergetUserNavigationhook