diff --git a/src/Twig/EasyAdminTwigExtension.php b/src/Twig/EasyAdminTwigExtension.php index 63df38b517..d1612b5446 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.')]), ]; } @@ -216,12 +218,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 9ac0f6441d..aada67fe88 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 %}