[!!!][TASK] Remove module URI storage in global variable
[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\ViewHelper\AbstractTagBasedViewHelper;
19
20 /**
21 * Create internal link tag within backend app
22 * @internal
23 */
24 class ModuleLinkViewHelper extends AbstractTagBasedViewHelper {
25
26 /**
27 * @var string
28 */
29 protected $tagName = 'a';
30
31 /**
32 * Arguments initialization
33 *
34 * @return void
35 */
36 public function initializeArguments() {
37 $this->registerUniversalTagAttributes();
38 $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
39 $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
40 $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
41 $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
42 }
43
44 /**
45 * Render module link with command and arguments
46 *
47 * @param string $controller The "controller" of scheduler. Possible values are "scheduler", "check", "info"
48 * @param string $action The action to be called within each controller
49 * @param array $arguments Arguments for the action
50 * @return string
51 */
52 public function render($controller, $action, array $arguments = array()) {
53 $moduleArguments = array();
54 $moduleArguments['SET']['function'] = $controller;
55 $moduleArguments['CMD'] = $action;
56 if (!empty($arguments)) {
57 $moduleArguments['tx_scheduler'] = $arguments;
58 }
59
60 $uri = BackendUtility::getModuleUrl('system_txschedulerM1', $moduleArguments);
61 $this->tag->addAttribute('href', $uri);
62 $this->tag->setContent($this->renderChildren());
63 $this->tag->forceClosingTag(TRUE);
64 return $this->tag->render();
65 }
66
67 }