Custom Eel Helpers
Support the documentation
This documentation was written by volunteers. Please help support our effort:
Help us improve the documentation
Eel Helpers provide methods that can be used inside of Eel expressions. That is mostly used to extend the capabilities for data-aquisition and processing of Fusion.
Define the class
The first step is to create the EelHelper class. Every Helper has to implement the interface Neos\Eel\ProtectedContextAwareInterface.
<?php
declare(strict_types=1);
namespace Vendor\Site\Eel\Helper;
use Neos\Flow\Annotations as Flow;
use Neos\Eel\ProtectedContextAwareInterface;
class ExampleHelper implements ProtectedContextAwareInterface {
/**
* Wrap the incoming string in curly brackets
*
* @param $text string
* @return string
*/
public function wrapInCurlyBrackets($text) {
return '{' . $text . '}';
}
/**
* All methods are considered safe, i.e. can be executed from within Eel
*
* @param string $methodName
* @return boolean
*/
public function allowsCallOfMethod($methodName) {
return true;
}
}
To make sure that the class is found, you need to define the composer autoloading in the packages composer.json. We recommend to use PSR-4, like this:
{
"name": "vendor/site",
"type": "neos-site",
"require": {
...
}
"autoload": {
"psr-4": {
"Vendor\\Site\\": "Classes"
}
},
...
}