[BUGFIX] Use late static binding for compilable viewhelpers
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / Classes / ViewHelpers / ModuleLinkViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Scheduler\ViewHelpers;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
21
22 /**
23 * Create internal link within backend app
24 * @internal
25 */
26 class ModuleLinkViewHelper extends AbstractViewHelper implements CompilableInterface {
27
28 /**
29 * Render module link with command and arguments
30 *
31 * @param string $controller The "controller" of scheduler. Possible values are "scheduler", "check", "info"
32 * @param string $action The action to be called within each controller
33 * @param array $arguments Arguments for the action
34 * @return string
35 */
36 public function render($controller, $action, array $arguments = array()) {
37 return static::renderStatic(
38 array(
39 'controller' => $controller,
40 'action' => $action,
41 'arguments' => $arguments,
42 ),
43 $this->buildRenderChildrenClosure(),
44 $this->renderingContext
45 );
46 }
47
48 /**
49 * @param array $arguments
50 * @param callable $renderChildrenClosure
51 * @param RenderingContextInterface $renderingContext
52 *
53 * @return string
54 */
55 static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
56 $moduleArguments = array();
57 $moduleArguments['SET']['function'] = $arguments['controller'];
58 $moduleArguments['CMD'] = $arguments['action'];
59 if (!empty($arguments['arguments'])) {
60 $moduleArguments['tx_scheduler'] = $arguments['arguments'];
61 }
62
63 return BackendUtility::getModuleUrl('system_txschedulerM1', $moduleArguments);
64 }
65
66 }