|
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.1 (http://modulestudio.de). |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Zikula\RoutesModule\Helper; |
|
14
|
|
|
|
|
15
|
|
|
use Symfony\Component\HttpFoundation\RequestStack; |
|
16
|
|
|
use Symfony\Component\Templating\EngineInterface; |
|
17
|
|
|
use Zikula\Bundle\CoreBundle\DynamicConfigDumper; |
|
18
|
|
|
use Zikula\Common\Translator\TranslatorInterface; |
|
19
|
|
|
use Zikula\ExtensionsModule\Api\ExtensionApi; |
|
20
|
|
|
use Zikula\ExtensionsModule\Api\VariableApi; |
|
21
|
|
|
use Zikula\ExtensionsModule\Entity\ExtensionEntity; |
|
22
|
|
|
use Zikula\ExtensionsModule\Entity\RepositoryInterface\ExtensionRepositoryInterface; |
|
23
|
|
|
use Zikula\PermissionsModule\Api\ApiInterface\PermissionApiInterface; |
|
24
|
|
|
use Zikula\RoutesModule\Entity\RouteEntity; |
|
25
|
|
|
use Zikula\RoutesModule\Helper\Base\AbstractViewHelper; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Utility implementation class for view helper methods. |
|
29
|
|
|
*/ |
|
30
|
|
|
class ViewHelper extends AbstractViewHelper |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var TranslatorInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
private $translator; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var DynamicConfigDumper |
|
39
|
|
|
*/ |
|
40
|
|
|
private $configDumper; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var ExtensionRepositoryInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
private $extensionRepository; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* ViewHelper constructor. |
|
49
|
|
|
* @param EngineInterface $templating EngineInterface service instance |
|
50
|
|
|
* @param RequestStack $requestStack RequestStack service instance |
|
51
|
|
|
* @param PermissionApiInterface $permissionApi PermissionApi service instance |
|
52
|
|
|
* @param VariableApi $variableApi VariableApi service instance |
|
53
|
|
|
* @param ControllerHelper $controllerHelper ControllerHelper service instance |
|
54
|
|
|
* @param TranslatorInterface $translator |
|
55
|
|
|
* @param DynamicConfigDumper $configDumper |
|
56
|
|
|
* @param ExtensionRepositoryInterface $extensionRepository |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __construct( |
|
59
|
|
|
EngineInterface $templating, |
|
60
|
|
|
RequestStack $requestStack, |
|
61
|
|
|
PermissionApiInterface $permissionApi, |
|
62
|
|
|
VariableApi $variableApi, |
|
63
|
|
|
ControllerHelper $controllerHelper, |
|
64
|
|
|
TranslatorInterface $translator, |
|
65
|
|
|
DynamicConfigDumper $configDumper, |
|
66
|
|
|
ExtensionRepositoryInterface $extensionRepository |
|
67
|
|
|
) { |
|
68
|
|
|
parent::__construct($templating, $requestStack, $permissionApi, $variableApi, $controllerHelper); |
|
69
|
|
|
$this->translator = $translator; |
|
70
|
|
|
$this->configDumper = $configDumper; |
|
71
|
|
|
$this->extensionRepository = $extensionRepository; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* {@inheritdoc} |
|
76
|
|
|
*/ |
|
77
|
|
|
public function processTemplate($type, $func, array $templateParameters = [], $template = '') |
|
78
|
|
|
{ |
|
79
|
|
|
$enrichedTemplateParameters = $templateParameters; |
|
80
|
|
|
|
|
81
|
|
|
if ($type == 'route' && $func == 'view') { |
|
82
|
|
|
$groupMessages = [ |
|
83
|
|
|
RouteEntity::POSITION_FIXED_TOP => $this->translator->__('Routes fixed to the top of the list:'), |
|
84
|
|
|
RouteEntity::POSITION_MIDDLE => $this->translator->__('Normal routes:'), |
|
85
|
|
|
RouteEntity::POSITION_FIXED_BOTTOM => $this->translator->__('Routes fixed to the bottom of the list:'), |
|
86
|
|
|
]; |
|
87
|
|
|
$enrichedTemplateParameters['groupMessages'] = $groupMessages; |
|
88
|
|
|
$enrichedTemplateParameters['sortableGroups'] = [RouteEntity::POSITION_MIDDLE]; |
|
89
|
|
|
|
|
90
|
|
|
$enrichedTemplateParameters['jms_i18n_routing'] = $this->configDumper->getConfigurationForHtml('jms_i18n_routing'); |
|
91
|
|
|
} elseif ($type == 'route' && $func == 'edit') { |
|
92
|
|
|
$urlNames = []; |
|
93
|
|
|
/** @var ExtensionEntity[] $modules */ |
|
94
|
|
|
$modules = $this->extensionRepository->findBy(['state' => ExtensionApi::STATE_ACTIVE]); |
|
95
|
|
|
foreach ($modules as $module) { |
|
96
|
|
|
$urlNames[$module->getName()] = $module->getUrl(); |
|
97
|
|
|
} |
|
98
|
|
|
$enrichedTemplateParameters['moduleUrlNames'] = $urlNames; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
return parent::processTemplate($type, $func, $enrichedTemplateParameters, $template); |
|
102
|
|
|
} |
|
103
|
|
|
} |
|
104
|
|
|
|