Skip to content

Commit

Permalink
Merge pull request #31 from paavo/master
Browse files Browse the repository at this point in the history
feat: Created EEL Helpers to provide MailObfuscator functions in Fusion
  • Loading branch information
networkteamcom authored Jun 8, 2023
2 parents 2701e93 + 567f1fb commit 111d2e3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Classes/Eel/MailObfuscator.php
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;
}
}
4 changes: 4 additions & 0 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Neos:
autoInclude:
'Networkteam.Neos.MailObfuscator': true

Fusion:
defaultContext:
Networkteam.Neos.MailObfuscator: 'Networkteam\Neos\MailObfuscator\Eel\MailObfuscator'

Networkteam:
Neos:
MailObfuscator:
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 111d2e3

Please sign in to comment.