‪TYPO3CMS  10.4
ActionViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
21 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
22 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
23 
37 class ‪ActionViewHelper extends AbstractViewHelper
38 {
39  use CompileWithRenderStatic;
40 
44  public function ‪initializeArguments()
45  {
46  $this->registerArgument('action', 'string', 'Target action', false);
47  $this->registerArgument('controller', 'string', 'Target controller.', false, 'maintenance');
48  $this->registerArgument('arguments', 'array', 'Arguments', false, []);
49  $this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
50  $this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []);
51  }
52 
59  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
60  {
61  $action = $arguments['action'];
62 
63  if ($action === 'backend') {
64  return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'index.php';
65  }
66  if ($action === 'frontend') {
67  return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php';
68  }
69 
70  $section = $arguments['section'];
71  $additionalParams = $arguments['additionalParams'];
72  $controller = $arguments['controller'];
73  $arguments = $arguments['arguments'];
74 
75  if (!empty($arguments['action'])) {
76  $arguments['action'] = $action;
77  }
78  $arguments['controller'] = $controller;
79  if (!empty(GeneralUtility::_GET('install')['context'])) {
80  $arguments['context'] = GeneralUtility::_GET('install')['context'];
81  }
82 
83  return GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')
85  array_merge(
86  ['install' => $arguments],
87  $additionalParams
88  ),
89  '?'
90  )
91  . ($section ? '#' . $section : '');
92  }
93 }
‪TYPO3\CMS\Install\ViewHelpers\Uri\ActionViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ActionViewHelper.php:58
‪TYPO3\CMS\Install\ViewHelpers\Uri\ActionViewHelper
Definition: ActionViewHelper.php:38
‪TYPO3\CMS\Install\ViewHelpers\Uri\ActionViewHelper\initializeArguments
‪initializeArguments()
Definition: ActionViewHelper.php:43
‪TYPO3\CMS\Install\ViewHelpers\Uri
Definition: ActionViewHelper.php:16
‪TYPO3\CMS\Core\Utility\HttpUtility\buildQueryString
‪static string buildQueryString(array $parameters, string $prependCharacter='', bool $skipEmptyParameters=false)
Definition: HttpUtility.php:163
‪TYPO3\CMS\Core\Utility\HttpUtility
Definition: HttpUtility.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46