[BUGFIX] Use late static binding for compilable viewhelpers
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Link / ActionViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Link;
3
4 /* *
5 * This script is part of the TYPO3 project - inspiring people to share! *
6 * *
7 * TYPO3 is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU General Public License version 2 as published by *
9 * the Free Software Foundation. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14 * Public License for more details. *
15 * */
16 /**
17 * A view helper for creating links to extbase actions.
18 *
19 * = Examples =
20 *
21 * <code title="link to the show-action of the current controller">
22 * <f:link.action action="show">action link</f:link.action>
23 * </code>
24 * <output>
25 * <a href="index.php?id=123&tx_myextension_plugin[action]=show&tx_myextension_plugin[controller]=Standard&cHash=xyz">action link</f:link.action>
26 * (depending on the current page and your TS configuration)
27 * </output>
28 */
29 class ActionViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper {
30
31 /**
32 * @var string
33 */
34 protected $tagName = 'a';
35
36 /**
37 * Arguments initialization
38 *
39 * @return void
40 */
41 public function initializeArguments() {
42 $this->registerUniversalTagAttributes();
43 $this->registerTagAttribute('name', 'string', 'Specifies the name of an anchor');
44 $this->registerTagAttribute('rel', 'string', 'Specifies the relationship between the current document and the linked document');
45 $this->registerTagAttribute('rev', 'string', 'Specifies the relationship between the linked document and the current document');
46 $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document');
47 }
48
49 /**
50 * @param string $action Target action
51 * @param array $arguments Arguments
52 * @param string $controller Target controller. If NULL current controllerName is used
53 * @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
54 * @param string $pluginName Target plugin. If empty, the current plugin name is used
55 * @param int $pageUid target page. See TypoLink destination
56 * @param int $pageType type of the target page. See typolink.parameter
57 * @param bool $noCache set this to disable caching for the target page. You should not need this.
58 * @param bool $noCacheHash set this to suppress the cHash query parameter created by TypoLink. You should not need this.
59 * @param string $section the anchor to be added to the URI
60 * @param string $format The requested format, e.g. ".html
61 * @param bool $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
62 * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
63 * @param bool $absolute If set, the URI of the rendered link is absolute
64 * @param bool $addQueryString If set, the current query parameters will be kept in the URI
65 * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
66 * @param string $addQueryStringMethod Set which parameters will be kept. Only active if $addQueryString = TRUE
67 * @return string Rendered link
68 */
69 public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $addQueryStringMethod = NULL) {
70 $uriBuilder = $this->controllerContext->getUriBuilder();
71 $uri = $uriBuilder->reset()->setTargetPageUid($pageUid)->setTargetPageType($pageType)->setNoCache($noCache)->setUseCacheHash(!$noCacheHash)->setSection($section)->setFormat($format)->setLinkAccessRestrictedPages($linkAccessRestrictedPages)->setArguments($additionalParams)->setCreateAbsoluteUri($absolute)->setAddQueryString($addQueryString)->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)->setAddQueryStringMethod($addQueryStringMethod)->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
72 $this->tag->addAttribute('href', $uri);
73 $this->tag->setContent($this->renderChildren());
74 $this->tag->forceClosingTag(TRUE);
75 return $this->tag->render();
76 }
77
78 }