Skip to content

Commit 111d2e3

Browse files
Merge pull request #31 from paavo/master
feat: Created EEL Helpers to provide MailObfuscator functions in Fusion
2 parents 2701e93 + 567f1fb commit 111d2e3

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

Classes/Eel/MailObfuscator.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
namespace Networkteam\Neos\MailObfuscator\Eel;
4+
5+
use Neos\Flow\Annotations as Flow;
6+
use Neos\Eel\ProtectedContextAwareInterface;
7+
use Networkteam\Neos\MailObfuscator\Converter\EmailLinkNameConverterInterface;
8+
use Networkteam\Neos\MailObfuscator\Converter\MailtoLinkConverterInterface;
9+
10+
/**
11+
* Eel helpers to provide MailObfuscator functions
12+
*/
13+
class MailObfuscator implements ProtectedContextAwareInterface {
14+
15+
/**
16+
* @var EmailLinkNameConverterInterface
17+
* @Flow\Inject
18+
*/
19+
protected $emailLinkNameConverter;
20+
21+
/**
22+
* @var MailtoLinkConverterInterface
23+
* @Flow\Inject
24+
*/
25+
protected $mailtoLinkConverter;
26+
27+
/**
28+
* Convert at Character
29+
*
30+
* @param $email string
31+
* @return string
32+
*/
33+
public function convertAtChar($email = false) {
34+
return $this->emailLinkNameConverter->convert($email);
35+
}
36+
37+
/**
38+
* Convert Mailto to Href
39+
*
40+
* @param $email string
41+
* @return string
42+
*/
43+
public function convertMailto2Href($email = false) {
44+
return $this->mailtoLinkConverter->convert($email);
45+
}
46+
47+
/**
48+
* All methods are considered safe
49+
*
50+
* @param string $methodName
51+
* @return boolean
52+
*/
53+
public function allowsCallOfMethod($methodName) {
54+
return true;
55+
}
56+
}

Configuration/Settings.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Neos:
1717
autoInclude:
1818
'Networkteam.Neos.MailObfuscator': true
1919

20+
Fusion:
21+
defaultContext:
22+
Networkteam.Neos.MailObfuscator: 'Networkteam\Neos\MailObfuscator\Eel\MailObfuscator'
23+
2024
Networkteam:
2125
Neos:
2226
MailObfuscator:

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ Networkteam:
7575
atCharReplacementString: '<img src="https://example.com/at-icon.png" alt="at" />'
7676
```
7777
78+
## EEL Helpers
79+
There are Eel helpers available to use MailObfuscator functions in Fusion
80+
81+
```
82+
// Convert @ Character
83+
${Networkteam.Neos.MailObfuscator.convertAtChar('[email protected]')}
84+
// returns: foo (at) example.com
85+
86+
```
87+
88+
```
89+
// Convert Mail to Href
90+
${Networkteam.Neos.MailObfuscator.convertMailto2Href('[email protected]')}
91+
// returns javascript:linkTo_UnCryptMailto('obfuscatedEmail', -randomNumber)
92+
```
93+
94+
7895
## Acknowledgments
7996

8097
Original email address obfuscation code by [TYPO3 CMS](http://www.typo3.org).

0 commit comments

Comments
 (0)