From 58a10ab248a8f3cff86cf8512471ed4feabf3d95 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Mon, 28 Oct 2024 12:42:48 +0100 Subject: [PATCH] feat: add "any" twig filter --- config/services.yaml | 2 ++ src/Twig/NeustaExtension.php | 28 ++++++++++++++++++++++++++++ templates/bricks/overview.html.twig | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/Twig/NeustaExtension.php diff --git a/config/services.yaml b/config/services.yaml index d99dcfa..c69769d 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -18,3 +18,5 @@ services: tags: - { name: kernel.event_listener, event: pimcore.bundle_manager.paths.css, method: addCSSFiles } - { name: kernel.event_listener, event: pimcore.bundle_manager.paths.js, method: addJSFiles } + + Neusta\Pimcore\AreabrickConfigBundle\Twig\NeustaExtension: ~ diff --git a/src/Twig/NeustaExtension.php b/src/Twig/NeustaExtension.php new file mode 100644 index 0000000..069f384 --- /dev/null +++ b/src/Twig/NeustaExtension.php @@ -0,0 +1,28 @@ + $v) { + if ($arrow($v, $k)) { + return true; + } + } + + return false; + } +} diff --git a/templates/bricks/overview.html.twig b/templates/bricks/overview.html.twig index df955bd..f6ce37f 100644 --- a/templates/bricks/overview.html.twig +++ b/templates/bricks/overview.html.twig @@ -1,6 +1,6 @@ -{% set hasVersions = bricks|filter(b => b.version is not empty)|length > 0 %} -{% set hasDescriptions = bricks|filter(b => b.description is not empty)|length > 0 %} -{% set hasAdditionalProperties = bricks|filter(b => b.additionalProperties is not empty)|length > 0 %} +{% set hasVersions = bricks|any(b => b.version is not empty) %} +{% set hasDescriptions = bricks|any(b => b.description is not empty) %} +{% set hasAdditionalProperties = bricks|any(b => b.additionalProperties is not empty) %}