|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Routes. |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Zikula contributors (Zikula) |
|
6
|
|
|
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License |
|
7
|
|
|
* @author Zikula contributors <[email protected]>. |
|
8
|
|
|
* @link http://www.zikula.org |
|
9
|
|
|
* @link http://zikula.org |
|
10
|
|
|
* @version Generated by ModuleStudio 0.7.0 (http://modulestudio.de). |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Zikula\RoutesModule\Menu\Base; |
|
14
|
|
|
|
|
15
|
|
|
use Knp\Menu\FactoryInterface; |
|
16
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait; |
|
18
|
|
|
use Zikula\Common\Translator\TranslatorTrait; |
|
19
|
|
|
use Zikula\RoutesModule\Entity\RouteEntity; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* This is the item actions menu implementation class. |
|
23
|
|
|
*/ |
|
24
|
|
|
class AbstractItemActionsMenu implements ContainerAwareInterface |
|
25
|
|
|
{ |
|
26
|
|
|
use ContainerAwareTrait; |
|
27
|
|
|
use TranslatorTrait; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Sets the translator. |
|
31
|
|
|
* |
|
32
|
|
|
* @param TranslatorInterface $translator Translator service instance |
|
33
|
|
|
*/ |
|
34
|
|
|
public function setTranslator(/*TranslatorInterface */$translator) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->translator = $translator; |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Builds the menu. |
|
41
|
|
|
* |
|
42
|
|
|
* @param FactoryInterface $factory Menu factory |
|
43
|
|
|
* @param array $options Additional options |
|
44
|
|
|
* |
|
45
|
|
|
* @return \Knp\Menu\MenuItem The assembled menu |
|
46
|
|
|
*/ |
|
47
|
|
|
public function menu(FactoryInterface $factory, array $options) |
|
48
|
|
|
{ |
|
49
|
|
|
$menu = $factory->createItem('itemActions'); |
|
50
|
|
|
if (!isset($options['entity']) || !isset($options['area']) || !isset($options['context'])) { |
|
51
|
|
|
return $menu; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$this->setTranslator($this->container->get('translator')); |
|
55
|
|
|
|
|
56
|
|
|
$entity = $options['entity']; |
|
57
|
|
|
$area = $options['area']; |
|
58
|
|
|
$context = $options['context']; |
|
59
|
|
|
|
|
60
|
|
|
$permissionApi = $this->container->get('zikula_permissions_module.api.permission'); |
|
61
|
|
|
$currentUserApi = $this->container->get('zikula_users_module.current_user'); |
|
|
|
|
|
|
62
|
|
|
$menu->setChildrenAttribute('class', 'list-inline'); |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
$currentLegacyControllerType = $area != '' ? $area : 'user'; |
|
66
|
|
|
$currentFunc = $context; |
|
67
|
|
|
|
|
68
|
|
|
if ($entity instanceof RouteEntity) { |
|
69
|
|
|
$component = 'ZikulaRoutesModule:Route:'; |
|
70
|
|
|
$instance = $entity['id'] . '::'; |
|
71
|
|
|
|
|
72
|
|
|
if ($currentLegacyControllerType == 'admin') { |
|
73
|
|
|
if (in_array($currentFunc, ['index', 'view'])) { |
|
74
|
|
|
$menu->addChild($this->__('Preview'), [ |
|
75
|
|
|
'route' => 'zikularoutesmodule_route_display', |
|
76
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
77
|
|
|
])->setAttribute('icon', 'fa fa-search-plus'); |
|
78
|
|
|
$menu[$this->__('Preview')]->setLinkAttribute('target', '_blank'); |
|
79
|
|
|
$menu[$this->__('Preview')]->setLinkAttribute('title', $this->__('Open preview page')); |
|
80
|
|
|
$menu->addChild($this->__('Details'), [ |
|
81
|
|
|
'route' => 'zikularoutesmodule_route_admindisplay', |
|
82
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
83
|
|
|
])->setAttribute('icon', 'fa fa-eye'); |
|
84
|
|
|
$menu[$this->__('Details')]->setLinkAttribute('title', str_replace('"', '', $entity->getTitleFromDisplayPattern())); |
|
85
|
|
|
} |
|
86
|
|
View Code Duplication |
if (in_array($currentFunc, ['index', 'view', 'display'])) { |
|
|
|
|
|
|
87
|
|
|
if ($permissionApi->hasPermission($component, $instance, ACCESS_EDIT)) { |
|
88
|
|
|
$menu->addChild($this->__('Edit'), [ |
|
89
|
|
|
'route' => 'zikularoutesmodule_route_adminedit', |
|
90
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
91
|
|
|
])->setAttribute('icon', 'fa fa-pencil-square-o'); |
|
92
|
|
|
$menu[$this->__('Edit')]->setLinkAttribute('title', $this->__('Edit this route')); |
|
93
|
|
|
$menu->addChild($this->__('Reuse'), [ |
|
94
|
|
|
'route' => 'zikularoutesmodule_route_adminedit', |
|
95
|
|
|
'routeParameters' => ['astemplate' => $entity['id']] |
|
96
|
|
|
])->setAttribute('icon', 'fa fa-files-o'); |
|
97
|
|
|
$menu[$this->__('Reuse')]->setLinkAttribute('title', $this->__('Reuse for new route')); |
|
98
|
|
|
} |
|
99
|
|
|
if ($permissionApi->hasPermission($component, $instance, ACCESS_DELETE)) { |
|
100
|
|
|
$menu->addChild($this->__('Delete'), [ |
|
101
|
|
|
'route' => 'zikularoutesmodule_route_admindelete', |
|
102
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
103
|
|
|
])->setAttribute('icon', 'fa fa-trash-o'); |
|
104
|
|
|
$menu[$this->__('Delete')]->setLinkAttribute('title', $this->__('Delete this route')); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
View Code Duplication |
if ($currentFunc == 'display') { |
|
|
|
|
|
|
108
|
|
|
$title = $this->__('Back to overview'); |
|
109
|
|
|
$menu->addChild($title, [ |
|
110
|
|
|
'route' => 'zikularoutesmodule_route_adminview' |
|
111
|
|
|
])->setAttribute('icon', 'fa fa-reply'); |
|
112
|
|
|
$menu[$title]->setLinkAttribute('title', $title); |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
if ($currentLegacyControllerType == 'user') { |
|
116
|
|
|
if (in_array($currentFunc, ['index', 'view'])) { |
|
117
|
|
|
$menu->addChild($this->__('Details'), [ |
|
118
|
|
|
'route' => 'zikularoutesmodule_route_display', |
|
119
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
120
|
|
|
])->setAttribute('icon', 'fa fa-eye'); |
|
121
|
|
|
$menu[$this->__('Details')]->setLinkAttribute('title', str_replace('"', '', $entity->getTitleFromDisplayPattern())); |
|
122
|
|
|
} |
|
123
|
|
View Code Duplication |
if (in_array($currentFunc, ['index', 'view', 'display'])) { |
|
|
|
|
|
|
124
|
|
|
if ($permissionApi->hasPermission($component, $instance, ACCESS_EDIT)) { |
|
125
|
|
|
$menu->addChild($this->__('Edit'), [ |
|
126
|
|
|
'route' => 'zikularoutesmodule_route_edit', |
|
127
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
128
|
|
|
])->setAttribute('icon', 'fa fa-pencil-square-o'); |
|
129
|
|
|
$menu[$this->__('Edit')]->setLinkAttribute('title', $this->__('Edit this route')); |
|
130
|
|
|
$menu->addChild($this->__('Reuse'), [ |
|
131
|
|
|
'route' => 'zikularoutesmodule_route_edit', |
|
132
|
|
|
'routeParameters' => ['astemplate' => $entity['id']] |
|
133
|
|
|
])->setAttribute('icon', 'fa fa-files-o'); |
|
134
|
|
|
$menu[$this->__('Reuse')]->setLinkAttribute('title', $this->__('Reuse for new route')); |
|
135
|
|
|
} |
|
136
|
|
|
if ($permissionApi->hasPermission($component, $instance, ACCESS_DELETE)) { |
|
137
|
|
|
$menu->addChild($this->__('Delete'), [ |
|
138
|
|
|
'route' => 'zikularoutesmodule_route_delete', |
|
139
|
|
|
'routeParameters' => ['id' => $entity['id']] |
|
140
|
|
|
])->setAttribute('icon', 'fa fa-trash-o'); |
|
141
|
|
|
$menu[$this->__('Delete')]->setLinkAttribute('title', $this->__('Delete this route')); |
|
142
|
|
|
} |
|
143
|
|
|
} |
|
144
|
|
View Code Duplication |
if ($currentFunc == 'display') { |
|
|
|
|
|
|
145
|
|
|
$title = $this->__('Back to overview'); |
|
146
|
|
|
$menu->addChild($title, [ |
|
147
|
|
|
'route' => 'zikularoutesmodule_route_view' |
|
148
|
|
|
])->setAttribute('icon', 'fa fa-reply'); |
|
149
|
|
|
$menu[$title]->setLinkAttribute('title', $title); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
return $menu; |
|
155
|
|
|
} |
|
156
|
|
|
} |
|
157
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..