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

Commit 153d565

Browse files
committed
forward addExtension call to inner factory
1 parent 3485ba8 commit 153d565

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

QuietFactory.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Cmf\Bundle\MenuBundle;
1313

14+
use Knp\Menu\Factory\ExtensionInterface;
1415
use Knp\Menu\FactoryInterface;
16+
use LogicException;
1517
use Psr\Log\LoggerInterface;
1618
use Symfony\Component\Routing\Exception\RouteNotFoundException;
1719

@@ -69,10 +71,28 @@ public function createItem($name, array $options = array())
6971
}
7072

7173
// remove route and content options
72-
unset($options['route']);
73-
unset($options['content']);
74+
unset($options['route'], $options['content']);
7475

7576
return $this->innerFactory->createItem($name, $options);
7677
}
7778
}
79+
80+
/**
81+
* Forward adding extensions to the wrapped factory.
82+
*
83+
* @param ExtensionInterface $extension
84+
* @param int $priority
85+
*
86+
* @throws \Exception if the inner factory does not implement the addExtension method.
87+
*/
88+
public function addExtension(ExtensionInterface $extension, $priority = 0)
89+
{
90+
if (!method_exists($this->innerFactory, 'addExtension')) {
91+
throw new LogicException(sprintf(
92+
'Wrapped factory "%s" does not have the method "addExtension".',
93+
get_class($this->innerFactory)
94+
));
95+
}
96+
$this->innerFactory->addExtension($extension, $priority);
97+
}
7898
}

0 commit comments

Comments
 (0)