-
The
ContentAwareFactory
and with it thecmf_menu.factory
service are removed. Theknp_menu.factory
service is now extended instead:Before
services: menu_builder: class: AppBundle\Menu\MenuBuilder arguments: ["@cmf_menu.factory"]
After
services: menu_builder: class: AppBundle\Menu\MenuBuilder arguments: ["@knp_menu.factory"]
-
The
loadFromNode
andloadFromArrays
are removed from the factory, use the NodeLoader or ArrayLoader instead:Before
$menuFactory->loadFromNode(...);
After
// the node loader is available as the cmf_menu.loader.node service $nodeLoader->load(...);
-
The
cmf_menu.voter
tag has been removed in favor ofknp_menu.voter
:Before
services: menu_voter: class: AppBundle\Menu\Voter\CurrentUrlVoter tags: - { name: cmf_menu.voter }
After
services: menu_voter: class: AppBundle\Menu\Voter\CurrentUrlVoter tags: - { name: knp_menu.voter }
-
Voters needing the master requests can now set the
request
option of theknp_menu.voter
tag:Before
services: request_menu_voter: class: AppBundle\Menu\Voter\RequestVoter calls: - [setRequest, ["@?request="]] tags: - { name: cmf_menu.voter }
After
services: request_menu_voter: class: AppBundle\Menu\Voter\RequestVoter tags: - { name: knp_menu.voter, request: true }
-
The
Symfony\Cmf\Bundle\MenuBundle\Voter\VoterInterface
is removed in favor ofKnp\Menu\Matcher\Voter\VoterInterface
:Before
// ... use Symfony\Cmf\Bundle\MenuBundle\Voter\VoterInterface; class CustomVoter implements VoterInterface { public function matchItem(ItemInterface $item = null) { // ... } }
After
// ... use Knp\Menu\Matcher\Voter\VoterInterface; class CustomVoter implements VoterInterface { public function matchItem(ItemInterface $item = null) { // ... } }
-
The event has no longer access to the menu factory:
Before
class CreateMenuItemFromNodeListener { public function onEvent(CreateMenuItemFromNodeEvent $event) { $event->getFactory()->createItem(...); } }
After
use Knp\Menu\FactoryInterface; class CreateMenuItemFromNodeListener { private $factory; // factory is available as the knp_menu.factory service public function __construct(FactoryInterface $factory) { $this->factory = $factory; } public function onEvent(CreateMenuItemFromNodeEvent $event) { $this->factory->createItem(...); } }