diff --git a/app/AppKernel.php b/app/AppKernel.php index 3789b32..4c1b43e 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -16,6 +16,7 @@ class AppKernel extends Kernel new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new AppBundle\AppBundle(), + new Knp\Bundle\MenuBundle\KnpMenuBundle(), ]; if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig index bafd28d..2a02745 100644 --- a/app/Resources/views/base.html.twig +++ b/app/Resources/views/base.html.twig @@ -7,6 +7,7 @@ + {{ knp_menu_render('AppBundle:Builder:mainMenu') }} {% block body %}{% endblock %} {% block javascripts %}{% endblock %} diff --git a/app/config/config.yml b/app/config/config.yml index 3292445..db0ec2d 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -66,3 +66,12 @@ swiftmailer: username: "%mailer_user%" password: "%mailer_password%" spool: { type: memory } + +knp_menu: + # use "twig: false" to disable the Twig extension and the TwigRenderer + twig: + template: KnpMenuBundle::menu.html.twig + # if true, enables the helper for PHP templates + templating: false + # the renderer to use, list is also available by default + default_renderer: twig \ No newline at end of file diff --git a/composer.json b/composer.json index c5e4989..6137841 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ "sensio/distribution-bundle": "^5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "^2.0", - "guzzlehttp/guzzle": "^6.2" + "guzzlehttp/guzzle": "^6.2", + "knplabs/knp-menu-bundle": "^2.0" }, "require-dev": { "sensio/generator-bundle": "^3.0", diff --git a/composer.lock b/composer.lock index 9578e75..ca8702d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6a0a087c1e2fc52f43e0cdb32405a4f1", - "content-hash": "6931eab7f98ea98f61f97e66ceeed392", + "hash": "949a476ee2ada40b63125ce056e2b419", + "content-hash": "70644053aa514d2ea5dd949b6ca6e7dd", "packages": [ { "name": "doctrine/annotations", @@ -1047,6 +1047,129 @@ ], "time": "2014-01-12 16:20:24" }, + { + "name": "knplabs/knp-menu", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/KnpMenu.git", + "reference": "964b5b3ca7fd23019147991f4f75f361d061eb20" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/KnpMenu/zipball/964b5b3ca7fd23019147991f4f75f361d061eb20", + "reference": "964b5b3ca7fd23019147991f4f75f361d061eb20", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "pimple/pimple": "~1.0", + "silex/silex": "~1.0", + "symfony/phpunit-bridge": "~2.7|~3.0", + "symfony/routing": "~2.3|~3.0", + "twig/twig": "~1.16|~2.0" + }, + "suggest": { + "pimple/pimple": "for the built-in implementations of the menu provider and renderer provider", + "silex/silex": "for the integration with your silex application", + "twig/twig": "for the TwigRenderer and the integration with your templates" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2-dev" + } + }, + "autoload": { + "psr-4": { + "Knp\\Menu\\": "src/Knp/Menu" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christophe Coevoet", + "email": "stof@notk.org" + }, + { + "name": "Knplabs", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/KnpLabs/KnpMenu/contributors" + } + ], + "description": "An object oriented menu library", + "homepage": "http://knplabs.com", + "keywords": [ + "menu", + "tree" + ], + "time": "2016-09-22 07:36:19" + }, + { + "name": "knplabs/knp-menu-bundle", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/KnpLabs/KnpMenuBundle.git", + "reference": "0e4af7209dc03e39c51ec70b68ab2ba3177c25de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/KnpLabs/KnpMenuBundle/zipball/0e4af7209dc03e39c51ec70b68ab2ba3177c25de", + "reference": "0e4af7209dc03e39c51ec70b68ab2ba3177c25de", + "shasum": "" + }, + "require": { + "knplabs/knp-menu": "~2.2", + "symfony/framework-bundle": "~2.3|~3.0" + }, + "require-dev": { + "symfony/expression-language": "~2.4|~3.0", + "symfony/phpunit-bridge": "~2.7|~3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Knp\\Bundle\\MenuBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christophe Coevoet", + "email": "stof@notk.org" + }, + { + "name": "KnpLabs", + "homepage": "http://knplabs.com" + }, + { + "name": "Symfony Community", + "homepage": "https://github.com/KnpLabs/KnpMenuBundle/contributors" + } + ], + "description": "This bundle provides an integration of the KnpMenu library", + "keywords": [ + "menu" + ], + "time": "2016-09-22 12:24:40" + }, { "name": "monolog/monolog", "version": "1.21.0", diff --git a/src/AppBundle/Menu/Builder.php b/src/AppBundle/Menu/Builder.php index 3c272a8..66e4e8f 100644 --- a/src/AppBundle/Menu/Builder.php +++ b/src/AppBundle/Menu/Builder.php @@ -1,12 +1,20 @@ createItem('root'); + + $menu->addChild('Home', [ + 'route' => 'homepage' + ]); + + return $menu; + } } \ No newline at end of file