Skip to content

Commit

Permalink
minor #259 Replace Request with RequestStack in docs (bocharsky-bw)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.0.x-dev branch.

Discussion
----------

Replace Request with RequestStack in docs

Since Symfony 2.4 better to use [RequestStack](http://symfony.com/blog/new-in-symfony-2-4-the-request-stack) instead of Request.

Commits
-------

6996447 Replace Request with RequestStack
  • Loading branch information
stof committed Jan 28, 2015
2 parents 320c2ab + 6996447 commit f6a5f9c
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions Resources/doc/menu_service.rst
Expand Up @@ -21,7 +21,7 @@ builder classes in your application:
namespace AppBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
class MenuBuilder
{
Expand All @@ -35,7 +35,7 @@ builder classes in your application:
$this->factory = $factory;
}
public function createMainMenu(Request $request)
public function createMainMenu(RequestStack $requestStack)
{
$menu = $this->factory->createItem('root');
Expand All @@ -61,8 +61,7 @@ object created by the ``createMainMenu`` method:
class: Knp\Menu\MenuItem # the service definition requires setting the class
factory_service: app.menu_builder
factory_method: createMainMenu
arguments: ["@request"]
scope: request # needed as we have the request as a dependency here
arguments: ["@request_stack"]
tags:
- { name: knp_menu.menu, alias: main } # The alias is what is used to retrieve the menu
Expand Down Expand Up @@ -93,7 +92,7 @@ is simple! Start by adding a new method to your builder:
{
// ...
public function createSidebarMenu(Request $request)
public function createSidebarMenu(RequestStack $requestStack)
{
$menu = $this->factory->createItem('sidebar');
Expand All @@ -115,8 +114,7 @@ Now, create a service for *just* your new menu, giving it a new name, like
class: Knp\Menu\MenuItem
factory_service: app.menu_builder
factory_method: createSidebarMenu
arguments: ["@request"]
scope: request
arguments: ["@request_stack"]
tags:
- { name: knp_menu.menu, alias: sidebar } # Named "sidebar" this time
Expand Down

0 comments on commit f6a5f9c

Please sign in to comment.