Compare commits

...
Sign in to create a new pull request.

8 commits

3 changed files with 46 additions and 3 deletions

View file

@ -12,6 +12,8 @@ namespace DigiComp\Menu\MenuService;
* source code.
*/
use Neos\Eel\EelEvaluatorInterface;
use Neos\Eel\Utility;
use Neos\Flow\Annotations as Flow;
/**
@ -30,6 +32,15 @@ class SettingsService implements ServiceInterface
*/
protected array $items = [];
#[Flow\InjectConfiguration(path: 'defaultEelContext', package: 'DigiComp.Menu')]
protected array $defaultContext = [];
/**
* @Flow\Inject
* @var EelEvaluatorInterface
*/
protected $eelEvaluator;
public function getItems(string $forPath = null): \Iterator
{
if ($forPath) {
@ -45,6 +56,21 @@ class SettingsService implements ServiceInterface
}
);
}
foreach ($items as $itemName => &$item) {
\array_walk_recursive(
$item,
fn (&$item) => $item =
\is_string($item) && \str_starts_with($item, '${') && \str_ends_with($item, '}')
? Utility::evaluateEelExpression(
$item,
$this->eelEvaluator,
[...$items, 'this' => $item, 'item' => $itemName],
$this->defaultContext
)
: $item
);
}
return new \ArrayIterator($items);
}
}

View file

@ -0,0 +1,17 @@
DigiComp:
Menu:
defaultEelContext:
String: 'Neos\Eel\Helper\StringHelper'
Array: 'Neos\Eel\Helper\ArrayHelper'
Date: 'Neos\Eel\Helper\DateHelper'
Configuration: 'Neos\Eel\Helper\ConfigurationHelper'
Math: 'Neos\Eel\Helper\MathHelper'
Json: 'Neos\Eel\Helper\JsonHelper'
Security: 'Neos\Eel\Helper\SecurityHelper'
Translation: 'Neos\Flow\I18n\EelHelper\TranslationHelper'
StaticResource: 'Neos\Flow\ResourceManagement\EelHelper\StaticResourceHelper'
Type: 'Neos\Eel\Helper\TypeHelper'
I18n: 'Neos\Flow\I18n\EelHelper\TranslationHelper'
File: 'Neos\Eel\Helper\FileHelper'
q: 'Neos\Eel\FlowQuery\FlowQuery::q'
BaseUri: 'Neos\Fusion\Eel\BaseUriHelper'

View file

@ -18,8 +18,8 @@
"license": "MIT",
"homepage": "https://github.com/digicomp/DigiComp.Menu",
"require": {
"neos/flow": "~6.3",
"php": "^7.4"
"neos/flow": "^7.3 | ^8.2",
"php": "^8.1"
},
"autoload": {
"psr-4": {
@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-develop": "3.0.x-dev",
"dev-develop": "4.0.x-dev",
"dev-version/2.x-dev": "2.0.x-dev"
},
"applied-flow-migrations": [