|
11 | 11 |
|
12 | 12 | namespace Symfony\Cmf\Bundle\MenuBundle;
|
13 | 13 |
|
14 |
| -use Knp\Menu\Silex\RouterAwareFactory; |
| 14 | +use Knp\Menu\MenuFactory; |
15 | 15 | use Knp\Menu\ItemInterface;
|
16 | 16 | use Knp\Menu\NodeInterface;
|
17 | 17 | use Knp\Menu\MenuItem;
|
|
37 | 37 | * The createItem method uses a voting process to decide whether the menu item
|
38 | 38 | * is the current item.
|
39 | 39 | */
|
40 |
| -class ContentAwareFactory extends RouterAwareFactory |
| 40 | +class ContentAwareFactory extends MenuFactory |
41 | 41 | {
|
42 | 42 | /**
|
43 | 43 | * @var UrlGeneratorInterface
|
@@ -83,7 +83,7 @@ public function __construct(
|
83 | 83 | LoggerInterface $logger
|
84 | 84 | )
|
85 | 85 | {
|
86 |
| - parent::__construct($generator); |
| 86 | + $this->generator = $generator; |
87 | 87 | $this->contentRouter = $contentRouter;
|
88 | 88 | $this->linkTypes = array('route', 'uri', 'content');
|
89 | 89 | $this->dispatcher = $dispatcher;
|
@@ -243,6 +243,22 @@ public function createItem($name, array $options = array())
|
243 | 243 | break;
|
244 | 244 | case 'route':
|
245 | 245 | unset($options['uri']);
|
| 246 | + |
| 247 | + try { |
| 248 | + $options['uri'] = $this->generator->generate( |
| 249 | + $options['route'], |
| 250 | + $options['routeParameters'], |
| 251 | + $options['routeAbsolute'] |
| 252 | + ); |
| 253 | + |
| 254 | + unset($options['route']); |
| 255 | + } catch (RouteNotFoundException $e) { |
| 256 | + $this->logger->error(sprintf('%s : %s', $name, $e->getMessage())); |
| 257 | + |
| 258 | + if (!$this->allowEmptyItems) { |
| 259 | + return null; |
| 260 | + } |
| 261 | + } |
246 | 262 | break;
|
247 | 263 | default:
|
248 | 264 | throw new \RuntimeException(sprintf('Internal error: unexpected linkType "%s"', $options['linkType']));
|
|
0 commit comments