[TASK] Streamline phpdoc annotations in EXT:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / BaseViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\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 TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
20
21 /**
22 * View helper which creates a <base href="..."></base> tag. The Base URI is taken from the
23 * current request.
24 * In TYPO3 Flow, you should always include this ViewHelper to make the links work.
25 *
26 * = Examples =
27 *
28 * <code title="Example">
29 * <f:base />
30 * </code>
31 * <output>
32 * <base href="http://yourdomain.tld/" />
33 * (depending on your domain)
34 * </output>
35 */
36 class BaseViewHelper extends AbstractViewHelper
37 {
38 use CompileWithRenderStatic;
39
40 /**
41 * As this ViewHelper renders HTML, the output must not be escaped.
42 *
43 * @var bool
44 */
45 protected $escapeOutput = false;
46
47 /**
48 * Render the "Base" tag by outputting $request->getBaseUri()
49 *
50 * Note: renders as <base></base>, because IE6 will else refuse to display
51 * the page...
52 *
53 * @param array $arguments
54 * @param \Closure $renderChildrenClosure
55 * @param RenderingContextInterface $renderingContext
56 *
57 * @return string "base"-Tag.
58 */
59 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
60 {
61 return '<base href="' . htmlspecialchars($renderingContext->getControllerContext()->getRequest()->getBaseUri()) . '" />';
62 }
63 }