‪TYPO3CMS  11.5
ExternalViewHelper.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 
18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
21 
47 class ‪ExternalViewHelper extends AbstractViewHelper
48 {
49  use CompileWithRenderStatic;
50 
56  public function ‪initializeArguments()
57  {
58  $this->registerArgument('uri', 'string', 'target URI', true);
59  $this->registerArgument('defaultScheme', 'string', 'scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'https');
60  }
61 
69  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
70  {
71  $uri = $arguments['uri'];
72  $defaultScheme = $arguments['defaultScheme'];
73 
74  $scheme = parse_url($uri, PHP_URL_SCHEME);
75  if ($scheme === null && $defaultScheme !== '') {
76  $uri = $defaultScheme . '://' . $uri;
77  }
78  return $uri;
79  }
80 }
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\ExternalViewHelper\renderStatic
‪static string renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: ExternalViewHelper.php:68
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\ExternalViewHelper
Definition: ExternalViewHelper.php:48
‪TYPO3\CMS\Fluid\ViewHelpers\Uri\ExternalViewHelper\initializeArguments
‪initializeArguments()
Definition: ExternalViewHelper.php:55
‪TYPO3\CMS\Fluid\ViewHelpers\Uri
Definition: ActionViewHelper.php:16