|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright 2017 Sourcefabric z.ú. and contributors. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please see the |
|
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright 2017 Sourcefabric z.ú |
|
14
|
|
|
* @license http://www.superdesk.org/license |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace SWP\Bundle\CoreBundle\Manager; |
|
18
|
|
|
|
|
19
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
20
|
|
|
use Knp\Menu\Factory\ExtensionInterface; |
|
21
|
|
|
use SWP\Bundle\ContentBundle\Model\RouteAwareInterface; |
|
22
|
|
|
use SWP\Bundle\MenuBundle\Doctrine\MenuItemRepositoryInterface; |
|
23
|
|
|
use SWP\Bundle\MenuBundle\Manager\MenuItemManager as BaseMenuItemManager; |
|
24
|
|
|
use SWP\Bundle\MenuBundle\Model\MenuItemInterface; |
|
25
|
|
|
|
|
26
|
|
|
final class MenuItemManager extends BaseMenuItemManager |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* MenuItemManager constructor. |
|
30
|
|
|
* |
|
31
|
|
|
* @param MenuItemRepositoryInterface $menuItemRepository |
|
32
|
|
|
* @param ObjectManager $objectManager |
|
33
|
|
|
* @param ExtensionInterface $extensionsChain |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
MenuItemRepositoryInterface $menuItemRepository, |
|
37
|
|
|
ObjectManager $objectManager, |
|
38
|
|
|
ExtensionInterface $extensionsChain |
|
39
|
|
|
) { |
|
40
|
|
|
parent::__construct($menuItemRepository, $objectManager, $extensionsChain); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function update(MenuItemInterface $menu) |
|
47
|
|
|
{ |
|
48
|
|
|
$options = []; |
|
49
|
|
|
|
|
50
|
|
|
if ($menu instanceof RouteAwareInterface) { |
|
51
|
|
|
$options = [ |
|
52
|
|
|
'route' => $menu->getRoute() ? $menu->getRoute()->getName() : null, |
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
$this->updateOptions($menu, $options); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|