-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from paavo/master
feat: Created EEL Helpers to provide MailObfuscator functions in Fusion
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
namespace Networkteam\Neos\MailObfuscator\Eel; | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Eel\ProtectedContextAwareInterface; | ||
use Networkteam\Neos\MailObfuscator\Converter\EmailLinkNameConverterInterface; | ||
use Networkteam\Neos\MailObfuscator\Converter\MailtoLinkConverterInterface; | ||
|
||
/** | ||
* Eel helpers to provide MailObfuscator functions | ||
*/ | ||
class MailObfuscator implements ProtectedContextAwareInterface { | ||
|
||
/** | ||
* @var EmailLinkNameConverterInterface | ||
* @Flow\Inject | ||
*/ | ||
protected $emailLinkNameConverter; | ||
|
||
/** | ||
* @var MailtoLinkConverterInterface | ||
* @Flow\Inject | ||
*/ | ||
protected $mailtoLinkConverter; | ||
|
||
/** | ||
* Convert at Character | ||
* | ||
* @param $email string | ||
* @return string | ||
*/ | ||
public function convertAtChar($email = false) { | ||
return $this->emailLinkNameConverter->convert($email); | ||
} | ||
|
||
/** | ||
* Convert Mailto to Href | ||
* | ||
* @param $email string | ||
* @return string | ||
*/ | ||
public function convertMailto2Href($email = false) { | ||
return $this->mailtoLinkConverter->convert($email); | ||
} | ||
|
||
/** | ||
* All methods are considered safe | ||
* | ||
* @param string $methodName | ||
* @return boolean | ||
*/ | ||
public function allowsCallOfMethod($methodName) { | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,23 @@ Networkteam: | |
atCharReplacementString: '<img src="https://example.com/at-icon.png" alt="at" />' | ||
``` | ||
## EEL Helpers | ||
There are Eel helpers available to use MailObfuscator functions in Fusion | ||
``` | ||
// Convert @ Character | ||
${Networkteam.Neos.MailObfuscator.convertAtChar('[email protected]')} | ||
// returns: foo (at) example.com | ||
|
||
``` | ||
``` | ||
// Convert Mail to Href | ||
${Networkteam.Neos.MailObfuscator.convertMailto2Href('[email protected]')} | ||
// returns javascript:linkTo_UnCryptMailto('obfuscatedEmail', -randomNumber) | ||
``` | ||
|
||
|
||
## Acknowledgments | ||
|
||
Original email address obfuscation code by [TYPO3 CMS](http://www.typo3.org). | ||
|