Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 54fb22f

Browse files
committed
Don't use decorates to keep Sf 2.3 support
1 parent 8d7b607 commit 54fb22f

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

CmfMenuBundle.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
use Symfony\Component\HttpKernel\Bundle\Bundle;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
16-
17-
use Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler\AddVotersPass;
16+
use Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler\DecorateMenuFactoryPass;
1817
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass;
1918

2019
class CmfMenuBundle extends Bundle
@@ -23,6 +22,8 @@ public function build(ContainerBuilder $container)
2322
{
2423
parent::build($container);
2524

25+
$container->addCompilerPass(new DecorateMenuFactoryPass());
26+
2627
if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) {
2728
$container->addCompilerPass(
2829
DoctrinePhpcrMappingsPass::createXmlMappingDriver(
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\MenuBundle\DependencyInjection\Compiler;
4+
5+
use Symfony\Component\DependencyInjection\Alias;
6+
use Symfony\Component\DependencyInjection\ContainerBuilder;
7+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
8+
9+
class DecorateMenuFactoryPass implements CompilerPassInterface
10+
{
11+
/**
12+
* {@inheritdoc}
13+
*
14+
* @todo Add `decorates="knp_menu.factory"` to the service definition
15+
* instead if Symfony 2.3 support is dropped.
16+
*/
17+
public function process(ContainerBuilder $container)
18+
{
19+
if (!$container->hasDefinition('knp_menu.factory')) {
20+
return;
21+
}
22+
23+
$knpFactory = $container->getDefinition('knp_menu.factory');
24+
$knpFactory->setPublic(false);
25+
26+
// rename old service
27+
$container->setDefinition('cmf_menu.factory.quiet.inner', $knpFactory);
28+
29+
$container->setAlias('knp_menu.factory', new Alias('cmf_menu.factory.quiet'));
30+
}
31+
}

Resources/config/menu.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
<service id="cmf_menu.content_router" alias="router"/>
1010

11-
<service id="cmf_menu.factory.quiet" class="Symfony\Cmf\Bundle\MenuBundle\QuietFactory"
12-
decorates="knp_menu.factory" public="false">
11+
<service id="cmf_menu.factory.quiet" class="Symfony\Cmf\Bundle\MenuBundle\QuietFactory" public="false">
1312
<argument type="service" id="cmf_menu.factory.quiet.inner" />
1413
<argument type="service" id="logger"/>
1514
<argument>%cmf_menu.allow_empty_items%</argument>

0 commit comments

Comments
 (0)