forked from Sylius/Stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbreadcrumbs.html.twig
More file actions
47 lines (40 loc) · 2.16 KB
/
breadcrumbs.html.twig
File metadata and controls
47 lines (40 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{% from '@SyliusBootstrapAdminUi/shared/helper/breadcrumbs.html.twig' import breadcrumbs %}
{% set configuration = hookable_metadata.context.configuration|default(null) %}
{% set resource = hookable_metadata.context.resource|default(null) %}
{% set metadata = hookable_metadata.context.metadata|default(null) %}
{% if configuration and metadata %}
{% set resource_index = metadata.applicationName~'.ui.'~metadata.pluralName %}
{% set index_url = path(
configuration.vars.index.route.name|default(configuration.getRouteName('index')),
configuration.vars.index.route.parameters|default(configuration.vars.route.parameters|default({}))
) %}
{% endif %}
{% set title = hookable_metadata.configuration.title|default(null) %}
{% set rendered_field_prefix = hookable_metadata.configuration.rendered_field_prefix|default(null) %}
{% set field_name = hookable_metadata.configuration.rendered_field|default('') %}
{% set rendered_field = rendered_field_prefix ~ (attribute(resource, field_name) is defined ? attribute(resource, field_name) : null) %}
{% set action = hookable_metadata.configuration.action|default(false)
? { name: hookable_metadata.configuration.action, active: false }
: {}
%}
{% set resource_show_name = title|default(rendered_field|default(resource.translations[app.locale].name|default(resource.code|default(resource.id|default(null))))) %}
{% if action is defined and action.name is defined %}
{% set show_url = path(configuration.getRouteName('show'), { id: resource.id }) %}
{% set resource_show = { name: resource_show_name, url: show_url} %}
{% else %}
{% set resource_show = { name: resource_show_name|default('sylius.ui.show'|trans), active: true} %}
{% endif %}
{% if resource_index is defined and index_url is defined %}
{{ breadcrumbs([
{ name: 'sylius.ui.dashboard', url: path('sylius_admin_ui_dashboard'), active: false },
{ name: resource_index, url: index_url, active: false },
resource_show,
action
]) }}
{% else %}
{{ breadcrumbs([
{ name: 'sylius.ui.dashboard', url: path('sylius_admin_ui_dashboard'), active: false },
resource_show,
action
]) }}
{% endif %}