diff --git a/composer.json b/composer.json index f6413ef965..eec2059513 100644 --- a/composer.json +++ b/composer.json @@ -33,13 +33,14 @@ "symfony/security-bundle": "^5.4|^6.0|^7.0", "symfony/string": "^5.4|^6.0|^7.0", "symfony/translation": "^5.4|^6.0|^7.0", + "symfony/twig-bridge": "^5.4,>=5.4.48|^6.0,>=6.4.16|^7.0,>=7.1.9", "symfony/twig-bundle": "^5.4|^6.0|^7.0", "symfony/uid": "^5.4|^6.0|^7.0", "symfony/ux-twig-component": "^2.21", "symfony/validator": "^5.4|^6.0|^7.0", "twig/extra-bundle": "^3.17", "twig/html-extra": "^3.17", - "twig/twig": "^3.15" + "twig/twig": "^3.20" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.4|3.5.x-dev", diff --git a/src/Twig/EasyAdminTwigExtension.php b/src/Twig/EasyAdminTwigExtension.php index 9dbec699ed..1583421122 100644 --- a/src/Twig/EasyAdminTwigExtension.php +++ b/src/Twig/EasyAdminTwigExtension.php @@ -14,6 +14,7 @@ use Symfony\Contracts\Translation\TranslatableInterface; use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\UX\Icons\Twig\UXIconRuntime; +use Twig\DeprecatedCallableInfo; use Twig\Environment; use Twig\Error\RuntimeError; use Twig\Extension\AbstractExtension; @@ -45,13 +46,13 @@ public function getFunctions(): array { return [ new TwigFunction('ea_url', [$this, 'getAdminUrlGenerator']), - new TwigFunction('ea_csrf_token', [$this, 'renderCsrfToken']), - new TwigFunction('ea_call_function_if_exists', [$this, 'callFunctionIfExists'], ['needs_environment' => true, 'is_safe' => ['html' => true]]), - new TwigFunction('ea_create_field_layout', [$this, 'createFieldLayout']), - new TwigFunction('ea_importmap', [$this, 'renderImportmap'], ['is_safe' => ['html']]), new TwigFunction('ea_form_ealabel', null, ['node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', 'is_safe' => ['html']]), - // TODO: remove this when Twig 3.15 is published and we can use the 'guard' tag - new TwigFunction('ea_ux_icon', [$this, 'renderIcon'], ['is_safe' => ['html']]), + // deprecated functions + new TwigFunction('ea_call_function_if_exists', [$this, 'callFunctionIfExists'], ['needs_environment' => true, 'is_safe' => ['html' => true], 'deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.21.0', 'No alternative is provided because it\'s no longer needed thanks to the Twig guard tag.')]), + new TwigFunction('ea_create_field_layout', [$this, 'createFieldLayout'], ['deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.8.0', 'No alternative is provided because it\'s no longer needed thanks to the new rendering engine')]), + new TwigFunction('ea_csrf_token', [$this, 'renderCsrfToken'], ['deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.21.0', 'No alternative is provided because it\'s no longer needed thanks to the Twig guard tag.')]), + new TwigFunction('ea_importmap', [$this, 'renderImportmap'], ['is_safe' => ['html'], 'deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.21.0', 'No alternative is provided because it\'s no longer needed thanks to the Twig guard tag.')]), + new TwigFunction('ea_ux_icon', [$this, 'renderIcon'], ['is_safe' => ['html'], 'deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.21.0', 'No alternative is provided because it\'s no longer needed thanks to the Twig guard tag.')]), ]; } @@ -60,8 +61,9 @@ public function getFilters(): array return [ new TwigFilter('ea_flatten_array', [$this, 'flattenArray']), new TwigFilter('ea_filesize', [$this, 'fileSize']), - new TwigFilter('ea_apply_filter_if_exists', [$this, 'applyFilterIfExists'], ['needs_environment' => true]), new TwigFilter('ea_as_string', [$this, 'representAsString']), + // deprecated filters + new TwigFilter('ea_apply_filter_if_exists', [$this, 'applyFilterIfExists'], ['needs_environment' => true, 'deprecation_info' => new DeprecatedCallableInfo('easycorp/easyadmin-bundle', '4.21.0', 'No alternative is provided because it\'s no longer needed thanks to the Twig guard tag.')]), ]; } @@ -226,12 +228,6 @@ public function renderCsrfToken(string $tokenId): string public function createFieldLayout(?FieldCollection $fieldDtos): FieldLayoutDto { - trigger_deprecation( - 'easycorp/easyadmin-bundle', - '4.8.0', - 'The "ea_create_field_layout()" Twig function is deprecated in favor of "ea_create_form_layout()" and it will be removed in 5.0.0.', - ); - return FormLayoutFactory::createFromFieldDtos($fieldDtos); } diff --git a/templates/components/Icon.html.twig b/templates/components/Icon.html.twig index a64c9da5d5..429ff53b34 100644 --- a/templates/components/Icon.html.twig +++ b/templates/components/Icon.html.twig @@ -6,7 +6,8 @@ {% elseif icon.svgContents %} {{ icon.svgContents|raw }} {% else %} - {# TODO: replace this by a call to ux_icon() function directly when Twig 3.15 is released and we can use the 'guard' tag #} - {{ ea_ux_icon(icon.name, attributes.all) }} + {% guard function ux_icon %} + {{ ux_icon(icon.name, attributes.all) }} + {% endguard %} {% endif %} diff --git a/templates/crud/form_theme.html.twig b/templates/crud/form_theme.html.twig index 38e4d99e70..c29e598490 100644 --- a/templates/crud/form_theme.html.twig +++ b/templates/crud/form_theme.html.twig @@ -362,7 +362,11 @@ {% if download_uri|default('') is empty %}
{% if formTypeOptions.imagine_pattern is defined and formTypeOptions.imagine_pattern is not empty %} - + {% guard filter imagine_filter %} + + {% else %} + + {% endguard %} {% else %} {% endif %} @@ -372,7 +376,11 @@ {% if formTypeOptions.imagine_pattern is defined and formTypeOptions.imagine_pattern is not empty %} - + {% guard filter imagine_filter %} + + {% else %} + + {% endguard %} {% else %} {% endif %} @@ -380,7 +388,11 @@
{% if formTypeOptions.imagine_pattern is defined and formTypeOptions.imagine_pattern is not empty %} - + {% guard filter imagine_filter %} + + {% else %} + + {% endguard %} {% else %} {% endif %} diff --git a/templates/crud/includes/_delete_form.html.twig b/templates/crud/includes/_delete_form.html.twig index 8009519c83..8cd4aec70b 100644 --- a/templates/crud/includes/_delete_form.html.twig +++ b/templates/crud/includes/_delete_form.html.twig @@ -1,6 +1,8 @@ {# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
- + {% guard function csrf_token %} + + {% endguard %}