accountable.html.twig 1.8 KB
Newer Older
Julien Jorry committed
1 2 3 4 5 6
{% extends admin.getTemplate('base_list_field') %}
{% block field %}
    <div>
	    {# {% if object is instanceof("App\\Entity\\Operation") %} #}
    	{% set objectFlux = null %}
    	{% if field_description.label|lower == 'expediteur' %}
7 8 9
    		{% if object.flux is not null %}
    			{% set objectFlux = object.account.accountableObject == object.flux.expediteur ? null : object.flux.expediteur %}
    		{% endif %}
Julien Jorry committed
10
    	{% elseif field_description.label|lower == 'destinataire' %}
11 12 13
    		{% if object.flux is not null %}
    			{% set objectFlux = object.account.accountableObject != object.flux.destinataire ? null : object.flux.destinataire %}
    		{% endif %}
Julien Jorry committed
14 15 16 17 18 19
    	{% elseif field_description.label|lower matches '/^Compte (groupe|comptoir|adherent|prestataire)/i' %}
    		{% set objectFlux = object.account.accountableObject %}
	    {% endif %}
	    {% if objectFlux is not null %}
	        {% if objectFlux is instanceof("App\\Entity\\Adherent") %}
				{% set name = 'Adherent' %}
20
				{% set editRoute = 'adherent_edit' %}
Julien Jorry committed
21 22
			{% elseif objectFlux is instanceof("App\\Entity\\Prestataire") %}
				{% set name = 'Prestataire' %}
23
				{% set editRoute = 'prestataire_edit' %}
Julien Jorry committed
24 25
			{% elseif objectFlux is instanceof("App\\Entity\\Comptoir") %}
				{% set name = 'Comptoir' %}
26
				{% set editRoute = 'comptoir_edit' %}
Julien Jorry committed
27 28
			{% elseif objectFlux is instanceof("App\\Entity\\Groupe") %}
				{% set name = 'Groupe' %}
29
				{% set editRoute = 'admin_app_groupe_edit' %}
Julien Jorry committed
30 31
			{% else %}
				{% set name = '' %}
32
				{% set editRoute = '' %}
Julien Jorry committed
33 34
			{% endif %}

35 36
		    {% if editRoute != '' %}
		        <a class="sonata-link-identifier" href="{{ path(editRoute, {'id': objectFlux.id}) }}">
Julien Jorry committed
37 38 39 40 41 42 43 44
		            {{ name ? '('~name~') ' }}{{ value }}
		        </a>
	    	{% else %}
		        {{ value }}
	    	{% endif %}
	    {% endif %}
    </div>
{% endblock %}