[Admin][Action] use dynamic crud action route name instead of static prefixed paths (#17514)

| Q               | A
|-----------------|-----
| Branch?         | 2.0 <!-- see the comment below -->
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes #17513
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.13 branch
 - Features and deprecations must be submitted against the 1.14 branch
- Features, removing deprecations and BC breaks must be submitted
against the 2.0 branch
 - Make sure that the correct base branch is set

To be sure you are not breaking any Backward Compatibilities, check the
documentation:

https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->
This commit is contained in:
Grzegorz Sadowski 2024-11-26 08:49:36 +01:00 committed by GitHub
commit 6707762b6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 9 deletions

View file

@ -1,8 +1,12 @@
{% set configuration = hookable_metadata.context.configuration %}
{% set update_route_name = configuration.vars.update.route.name|default(configuration.getRouteName('update')) %}
{% if sylius_route_exists(update_route_name) %}
{% set resource_id = hookable_metadata.context.resource.id %}
{% set resource_name = hookable_metadata.context.metadata.name %}
{% set url = 'sylius_admin_' ~ resource_name ~ '_update' %}
<a class="btn" href="{{ path(url, {'id': resource_id}) }}" {{ sylius_test_html_attribute('edit-' ~ resource_name) }}>
<a class="btn" href="{{ path(update_route_name, {'id': resource_id}) }}" {{ sylius_test_html_attribute('edit-' ~ resource_name) }}>
{{ ux_icon('tabler:pencil') }}
{{ 'sylius.ui.edit'|trans }}
</a>
{% endif %}

View file

@ -4,9 +4,8 @@
{% if sylius_route_exists(show_route_name) %}
{% set resource_id = hookable_metadata.context.resource.id %}
{% set resource_name = hookable_metadata.context.metadata.name %}
{% set url = 'sylius_admin_' ~ resource_name ~ '_show' %}
<a class="btn" href="{{ path(url, {'id': resource_id}) }}" {{ sylius_test_html_attribute('show-' ~ resource_name) }}>
<a class="btn" href="{{ path(show_route_name, {'id': resource_id}) }}" {{ sylius_test_html_attribute('show-' ~ resource_name) }}>
{{ ux_icon('tabler:eye') }}
{{ 'sylius.ui.show'|trans }}
</a>