Example Eel Helper

Your own Eel Helper can be very useful. They connect PHP to Fusion and can be used in any Fusion file. You can see the example at the bottom of each page: "Last cache from year-month-day at hour:minutes:seconds (Example Eel Helper)". If you want to see how to link a NodeType and PHP look at Example Plugin


Look what's behind it:

<?php
namespace Arsors\Neos\EelHelper;

use Neos\Flow\Annotations as Flow;
use Neos\Eel\ProtectedContextAwareInterface;

class ExampleEelHelper implements ProtectedContextAwareInterface
{

/**
* @param Array $parameter
* @return string
*/
public function example($parameter) {

$date = new \DateTime();
return '<center class="f-black mt-5"><span class="badge badge-pill badge-secondary">'.$parameter[0].$date->format('Y-m-d').$parameter[1].$date->format('H:i:s').$parameter[2].'</span></center>';

}

/**
* All methods are considered safe
*
* @param string $methodName
* @return boolean
*/
public function allowsCallOfMethod($methodName)
{
return true;
}

}

Neos:
  Fusion:
    defaultContext:
      'EelHelper': 'Arsors\Neos\EelHelper\ExampleEelHelper'

prototype(Arsors.Neos:DefaultPage) < prototype(Neos.Neos:Page) {
    body {
        [...]

        ExampleEelHelper = ${ EelHelper.example(["Last cache from  "," at ", " (Example Eel Helper)"]) }

        [...]
    }
}

<!DOCTYPE html>
{namespace neos=Neos\Neos\ViewHelpers}
{namespace fusion=Neos\Fusion\ViewHelpers}
<html>
<head>
[...]
</head>
<body>
<f:section name="body">

    {ExampleEelHelper -> f:format.raw()}

</f:section>
[...]
</body>
</html>
Last cache from 2020-10-06 at 08:32:17 (Example Eel Helper)