[TASK] Streamline phpdoc annotations in EXT:fluid
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Uri / EmailViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
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 * Email URI view helper.
23 * Generates an email URI incorporating TYPO3s spamProtectEmailAddresses-settings.
24 *
25 * = Examples
26 *
27 * <code title="basic email URI">
28 * <f:uri.email email="foo@bar.tld" />
29 * </code>
30 * <output>
31 * javascript:linkTo_UnCryptMailto('ocknvq,hqqBdct0vnf');
32 * (depending on your spamProtectEmailAddresses-settings)
33 * </output>
34 */
35 class EmailViewHelper extends AbstractViewHelper
36 {
37 use CompileWithRenderStatic;
38
39 /**
40 * Initialize arguments
41 */
42 public function initializeArguments()
43 {
44 $this->registerArgument('email', 'string', 'The email address to be turned into a URI', true);
45 }
46
47 /**
48 * @param array $arguments
49 * @param \Closure $renderChildrenClosure
50 * @param RenderingContextInterface $renderingContext
51 *
52 * @return string Rendered email link
53 */
54 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
55 {
56 $email = $arguments['email'];
57
58 if (TYPO3_MODE === 'FE') {
59 $emailParts = $GLOBALS['TSFE']->cObj->getMailTo($email, $email);
60 return reset($emailParts);
61 }
62 return 'mailto:' . $email;
63 }
64 }