Answer the question
In order to leave comments, you need to log in
How to call Entity Manager in KnpMenu in Symfony 2?
There is a service that implements Breadcrumbs using KnpMenu
services:
app.one:
class: App\AdminBundle\Menu\BreadscampBuilder
arguments:
- ["@knp_menu.factory"]
app.breadcrumb:
class: Knp\Menu\MenuItem
factory_service: app.one
factory_method: createBreadcrumbMenu
arguments: ["@request"]
scope: request
tags:
- { name: knp_menu.menu, alias: breadcrumb }
namespace App\AdminBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;
class BreadscampBuilder
{
private $factory;
/**
* @param FactoryInterface $factory
*/
public function __construct(FactoryInterface $factory)
{
$this->factory = $factory;
}
public function createBreadcrumbMenu(Request $request)
{
// Как тут вызвать entityManager ?
}
return $menu;
}
}
protected $entityManager;
public function __construct($entityManager)
{
$this->entityManager = $entityManager;
}
arguments:
entityManager: "@doctrine.orm.entity_manager"
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question