TYPO3 CMS  TYPO3_8-7
ActionViewHelper.php
Go to the documentation of this file.
1 <?php
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 
20 
34 {
36 
42  public function initializeArguments()
43  {
44  parent::initializeArguments();
45  $this->registerArgument('action', 'string', 'Target action');
46  $this->registerArgument('controller', 'string', 'Target controller.', false, 'tool');
47  $this->registerArgument('arguments', 'array', 'Arguments', false, []);
48  $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
49  $this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []);
50  }
51 
58  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
59  {
60  $action = $arguments['action'];
61 
62  if ($action === 'backend') {
63  return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'index.php';
64  }
65  if ($action === 'frontend') {
66  return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php';
67  }
68 
69  $section = $arguments['section'];
70  $additionalParams = $arguments['additionalParams'];
71  $controller = $arguments['controller'];
72  $arguments = $arguments['arguments'];
73 
74  $arguments['action'] = $action;
75  $arguments['controller'] = $controller;
76  if (!empty(GeneralUtility::_GET('install')['context'])) {
77  $arguments['context'] = GeneralUtility::_GET('install')['context'];
78  }
79 
80  return GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')
81  . '?'
82  . GeneralUtility::implodeArrayForUrl('install', $arguments)
83  . GeneralUtility::implodeArrayForUrl('', $additionalParams)
84  . ($section ? '#' . $section : '');
85  }
86 }
static implodeArrayForUrl($name, array $theArray, $str='', $skipBlank=false, $rawurlencodeParamName=false)
static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)