[BUGFIX] Use late static binding for compilable viewhelpers
[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 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 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
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 implements CompilableInterface {
36
37 /**
38 * @param string $email The email address to be turned into a URI
39 * @return string Rendered email link
40 */
41 public function render($email) {
42 return static::renderStatic(
43 array(
44 'email' => $email
45 ),
46 $this->buildRenderChildrenClosure(),
47 $this->renderingContext
48 );
49 }
50
51 /**
52 * @param array $arguments
53 * @param callable $renderChildrenClosure
54 * @param RenderingContextInterface $renderingContext
55 *
56 * @return string
57 */
58 static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
59 $email = $arguments['email'];
60
61 if (TYPO3_MODE === 'FE') {
62 $emailParts = $GLOBALS['TSFE']->cObj->getMailTo($email, $email);
63 return reset($emailParts);
64 } else {
65 return 'mailto:' . $email;
66 }
67 }
68
69 }