diff --git a/DependencyInjection/ChillMainExtension.php b/DependencyInjection/ChillMainExtension.php index 44c2d2034..613fe048e 100644 --- a/DependencyInjection/ChillMainExtension.php +++ b/DependencyInjection/ChillMainExtension.php @@ -97,6 +97,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, $loader->load('services/controller.yml'); $loader->load('services/routing.yml'); $loader->load('services/fixtures.yml'); + $loader->load('services/menu.yml'); } public function getConfiguration(array $config, ContainerBuilder $container) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 2b1562379..989a5e8f3 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -79,10 +79,4 @@ login_check: path: /login_check logout: - path: /logout - options: - menus: - user: - order: 10 - label: Logout - icon: power-off \ No newline at end of file + path: /logout \ No newline at end of file diff --git a/Resources/test/Fixtures/App/app/AppKernel.php b/Resources/test/Fixtures/App/app/AppKernel.php index 7f7b0de1f..10886518a 100644 --- a/Resources/test/Fixtures/App/app/AppKernel.php +++ b/Resources/test/Fixtures/App/app/AppKernel.php @@ -18,6 +18,7 @@ class AppKernel extends Kernel new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(), new Symfony\Bundle\MonologBundle\MonologBundle(), new Knp\Bundle\MenuBundle\KnpMenuBundle(), + new Symfony\Bundle\DebugBundle\DebugBundle() ); } diff --git a/Routing/MenuBuilder/UserMenuBuilder.php b/Routing/MenuBuilder/UserMenuBuilder.php new file mode 100644 index 000000000..131e4c00f --- /dev/null +++ b/Routing/MenuBuilder/UserMenuBuilder.php @@ -0,0 +1,46 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +namespace Chill\MainBundle\Routing\MenuBuilder; + +use Chill\MainBundle\Routing\LocalMenuBuilderInterface; + +/** + * + * + * @author Julien Fastré + */ +class UserMenuBuilder implements LocalMenuBuilderInterface +{ + public function buildMenu($menuId, \Knp\Menu\MenuItem $menu, array $parameters) + { + $menu->addChild( + 'Logout', + [ + 'route' => 'logout' + ]) + ->setExtras([ + 'order'=> 10, + 'icon' => 'power-off' + ]); + } + + public static function getMenuIds(): array + { + return [ 'user' ]; + } +}