Skip to content

Commit

Permalink
Merge pull request #42 from altercampagne/add-twig-cs-fixer
Browse files Browse the repository at this point in the history
Install twig-cs-fixer & use it
  • Loading branch information
odolbeau authored Dec 18, 2024
2 parents 65e62d2 + 0e00102 commit 0617540
Show file tree
Hide file tree
Showing 52 changed files with 1,296 additions and 124 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ jobs:
- name: PHP-CS-Fixer
run: tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff --config=.php-cs-fixer.dist.php

twig-cs-fixer:
name: Twig CS Fixer
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- name: Install twig-cs-fixer
uses: ramsey/composer-install@v2
with:
composer-options: "--working-dir=tools/twig-cs-fixer"

- name: Twig CS Fixer
run: tools/twig-cs-fixer/vendor/bin/twig-cs-fixer lint

linters:
name: 🧹 Linters
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@

/tools/*/vendor
/.phpstan-cache
/.twig-cs-fixer.cache
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ cs-lint: ## Lint all files
@$(DOCKER_COMPOSE) run php bin/console lint:yaml config/
@$(DOCKER_COMPOSE) run php composer install --working-dir=tools/php-cs-fixer
@$(DOCKER_COMPOSE) run php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run --diff
@$(DOCKER_COMPOSE) run php tools/twig-cs-fixer/vendor/bin/twig-cs-fixer lint

cs-fix: ## Fix CS using PHP-CS
@$(DOCKER_COMPOSE) run php composer install --working-dir=tools/php-cs-fixer
@$(DOCKER_COMPOSE) run php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix
@$(DOCKER_COMPOSE) run php tools/twig-cs-fixer/vendor/bin/twig-cs-fixer fix
2 changes: 1 addition & 1 deletion templates/_skeleton.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{% block title %}AlterCampagne{% endblock %}</title>
<meta name="description" content="{% block meta_description %}Site de gestion des inscriptions d'AlterCampagne{% endblock%}">
<meta name="description" content="{% block meta_description %}Site de gestion des inscriptions d'AlterCampagne{% endblock %}">

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
Expand Down
6 changes: 3 additions & 3 deletions templates/admin/_cards/alternative.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{{ alternative.name }}
</div>
<div>
<a href="{{ path('alternative_show', { slug: alternative.slug }) }}">Voir sur le site</a>
<a href="{{ path('alternative_show', {slug: alternative.slug}) }}">Voir sur le site</a>
{% if descriptionLength < 500 %}
<span class="badge bg-{{ descriptionLength < 200 ? 'danger' : 'warning' }} ms-1" data-bs-toggle="tooltip" title="La description est {{ descriptionLength >= 200 ? '(un peu) ' }}trop courte ({{ descriptionLength }} caractères) !">
D
Expand Down Expand Up @@ -44,7 +44,7 @@
{% for event, stages in alternative.stagesByEvent %}
<b><u>{{ (stages|first).event.name }} :</u></b>
{% for stage in stages %}
<a href="{{ path ('admin_stage_show', { slug: stage.slug }) }}" class="text-decoration-none ms-1">
<a href="{{ path ('admin_stage_show', {slug: stage.slug}) }}" class="text-decoration-none ms-1">
<span class="badge bg-secondary">{{ stage.name }}</span>
</a>
{% endfor %}
Expand All @@ -61,6 +61,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_alternative_show', { slug: alternative.slug }) }}" class="btn btn-link btn-sm">Voir l'alternative</a>
<a href="{{ path('admin_alternative_show', {slug: alternative.slug}) }}" class="btn btn-link btn-sm">Voir l'alternative</a>
{% endblock %}
</div>
4 changes: 2 additions & 2 deletions templates/admin/_cards/companion.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% endif %}

<li class="list-group-item">
<a href="mailto:{{ companion.email}}">
<a href="mailto:{{ companion.email }}">
{{ companion.email }}
</a>
</li>
Expand All @@ -27,5 +27,5 @@
{% endif %}
</ul>

<a href="{{ path('admin_user_show', { id: companion.user.id }) }}" class="btn btn-link btn-sm">Voir l'utilisateurice {{ companion.user.fullName }}</a>
<a href="{{ path('admin_user_show', {id: companion.user.id}) }}" class="btn btn-link btn-sm">Voir l'utilisateurice {{ companion.user.fullName }}</a>
</div>
2 changes: 1 addition & 1 deletion templates/admin/_cards/event.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_event_show', { slug: event.slug }) }}" class="btn btn-link btn-sm">Voir l'évènement</a>
<a href="{{ path('admin_event_show', {slug: event.slug}) }}" class="btn btn-link btn-sm">Voir l'évènement</a>
{% endblock %}
</div>
4 changes: 2 additions & 2 deletions templates/admin/_cards/payment.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Paiement de {{ payment.amount|format_price }} découpé comme suit :
<ul>
{% if payment.registration is not null %}
<li>{{ payment.amountWithoutMemberships|format_price }} pour <a href="{{ path('admin_registration_show', { id: payment.registration.id }) }}">une inscription</a></li>
<li>{{ payment.amountWithoutMemberships|format_price }} pour <a href="{{ path('admin_registration_show', {id: payment.registration.id}) }}">une inscription</a></li>
{% endif %}
{% for membership in payment.memberships %}
<li>{{ membership.price|format_price }} pour l'adhésion de <b>{{ membership.person.fullname }}</b></li>
Expand Down Expand Up @@ -65,6 +65,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_payment_show', { id: payment.id }) }}" class="btn btn-link btn-sm">Voir ce paiement</a>
<a href="{{ path('admin_payment_show', {id: payment.id}) }}" class="btn btn-link btn-sm">Voir ce paiement</a>
{% endblock %}
</div>
2 changes: 1 addition & 1 deletion templates/admin/_cards/registration.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_registration_show', { id: registration.id }) }}" class="btn btn-link btn-sm">Voir cette inscription</a>
<a href="{{ path('admin_registration_show', {id: registration.id}) }}" class="btn btn-link btn-sm">Voir cette inscription</a>
{% endblock %}
</div>
8 changes: 4 additions & 4 deletions templates/admin/_cards/stage.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
{% endif %}
<li class="list-group-item">
<i class="fa-solid fa-calendar-days fa-fw me-1" data-bs-toggle="tooltip" title="L'évènement lié à cette étape"></i>
<a href="{{ path('admin_event_show', { slug: stage.event.slug }) }}" data-bs-toggle="tooltip" title="Voir l'évènement">
<a href="{{ path('admin_event_show', {slug: stage.event.slug}) }}" data-bs-toggle="tooltip" title="Voir l'évènement">
{{ stage.event.name }}
</a>
</li>
<li class="list-group-item">
<i class="fa-solid fa-map-location-dot fa-fw me-1" data-bs-toggle="tooltip" title="Les alternatives traversées"></i>
{% for alternative in stage.alternatives %}
<a href="{{ path('admin_alternative_show', { slug: alternative.slug }) }}" data-bs-toggle="tooltip" title="Voir l'alternative">
<a href="{{ path('admin_alternative_show', {slug: alternative.slug}) }}" data-bs-toggle="tooltip" title="Voir l'alternative">
<span class="badge bg-primary">{{ alternative.name }}</span>
</a>
{% else %}
Expand All @@ -40,7 +40,7 @@
<li class="list-group-item">
<i class="fa-solid fa-users fa-fw me-1" data-bs-toggle="tooltip" title="Les préparateurices d'étape"></i>
{% for preparer in stage.preparers %}
<a href="{{ path('admin_user_show', { id: preparer.id }) }}" data-bs-toggle="tooltip" title="Voir cette personne">
<a href="{{ path('admin_user_show', {id: preparer.id}) }}" data-bs-toggle="tooltip" title="Voir cette personne">
<span class="badge bg-primary">{{ preparer.fullName }}</span>
</a>
{% else %}
Expand All @@ -51,6 +51,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_stage_show', { slug: stage.slug }) }}" class="btn btn-link btn-sm">Voir l'étape</a>
<a href="{{ path('admin_stage_show', {slug: stage.slug}) }}" class="btn btn-link btn-sm">Voir l'étape</a>
{% endblock %}
</div>
4 changes: 2 additions & 2 deletions templates/admin/_cards/user.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
data-bs-toggle="tooltip"
data-bs-title="Email{% if not user.isVerified %} non{% endif %} vérifié"
></i>
<a href="mailto:{{ user.email}}">
<a href="mailto:{{ user.email }}">
{{ user.email }}
</a>
</div>
Expand All @@ -71,6 +71,6 @@
{% endblock %}

{% block footer %}
<a href="{{ path('admin_user_show', { id: user.id }) }}" class="btn btn-link btn-sm">Voir ce·tte utilisateurice</a>
<a href="{{ path('admin_user_show', {id: user.id}) }}" class="btn btn-link btn-sm">Voir ce·tte utilisateurice</a>
{% endblock %}
</div>
4 changes: 2 additions & 2 deletions templates/admin/alternative/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% for event in events %}
<a
class="badge bg-{{ event.isPublished ? 'success' : 'warning' }} text-decoration-none"
href="{{ path('admin_alternative_list', { event: event.slug }) }}"
href="{{ path('admin_alternative_list', {event: event.slug}) }}"
data-bs-toggle="tooltip"
title="{% if event.isPublished %}Cet évènement est publié depuis le {{ event.publishedAt|format_date }}{% else %}Cet évènement n'est pas encore publié{% endif %}"
>
Expand Down Expand Up @@ -71,7 +71,7 @@
<td>{{ alternative.createdAt|format_datetime }}</td>
<td>
{% if is_granted(constant('App\\Admin\\Security\\Permission::ALTERNATIVE_VIEW').value, alternative) %}
<twig:Admin:IconView url="{{ path('admin_alternative_show', { slug: alternative.slug }) }}" />
<twig:Admin:IconView url="{{ path('admin_alternative_show', {slug: alternative.slug}) }}" />
{% endif %}
</td>
</tr>
Expand Down
8 changes: 4 additions & 4 deletions templates/admin/alternative/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>

<div class="col-12 col-md-8">
{% embed 'admin/_cards/alternative.html.twig' with { alternative: alternative } only %}
{% embed 'admin/_cards/alternative.html.twig' with {alternative: alternative} only %}
{% block content %}
{{ parent() }}

Expand Down Expand Up @@ -44,7 +44,7 @@
{% for station in alternative.stations %}
<div>
<i class="fa-solid fa-{{ station.type }} fa-fw" data-bs-toggle="tooltip" title="Gare de {{ station.type }}"></i>
{{station.name }} <span class="text-secondary">({{ station.distance }} kms)</span>
{{ station.name }} <span class="text-secondary">({{ station.distance }} kms)</span>
</div>
{% else %}
<div class="alert bg-danger-subtle mb-0">Aucune gare définie !</div>
Expand All @@ -56,7 +56,7 @@
{% block footer %}
<div class="d-grid gap-2 p-2">
{% if is_granted(constant('App\\Admin\\Security\\Permission::ALTERNATIVE_UPDATE').value, alternative) %}
<a href="{{ path('admin_alternative_update', { slug: alternative.slug }) }}" class="btn btn-outline-primary">Modifier l'alternative</a>
<a href="{{ path('admin_alternative_update', {slug: alternative.slug}) }}" class="btn btn-outline-primary">Modifier l'alternative</a>
{% endif %}

{% if is_granted(constant('App\\Admin\\Security\\Permission::ALTERNATIVE_DELETE').value, alternative) %}
Expand All @@ -66,7 +66,7 @@
</button>
{% else %}
<twig:Admin:ButtonDelete
url="{{ path('admin_alternative_delete', { slug: alternative.slug }) }}"
url="{{ path('admin_alternative_delete', {slug: alternative.slug}) }}"
buttonLabel="Supprimer l'alternative"
/>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions templates/admin/dashboard.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h2 class="text-center">Évènements à venir</h2>
{% for event in events %}
<div class="mb-3">
{{ include('admin/_cards/event.html.twig', { event: event }, with_context=false) }}
{{ include('admin/_cards/event.html.twig', {event: event}, with_context: false) }}
</div>
{% else %}
<div class="text-center">
Expand All @@ -27,7 +27,7 @@
</div>
{% for alternative in alternatives %}
<div class="mb-3">
{{ include('admin/_cards/alternative.html.twig', { alternative: alternative }, with_context=false) }}
{{ include('admin/_cards/alternative.html.twig', {alternative: alternative}, with_context: false) }}
</div>
{% else %}
<div class="text-center">
Expand Down
2 changes: 1 addition & 1 deletion templates/admin/event/edit.html.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends 'admin/_base.html.twig' %}

{% set title = creation ? 'Création d\'un évènement de type '~(event.type|trans) : 'Modification de l\'évènement '~form.vars.data.name %}
{% set title = creation ? 'Création d\'un évènement de type ' ~ (event.type|trans) : 'Modification de l\'évènement ' ~ form.vars.data.name %}

{% block main %}
<div class="container">
Expand Down
6 changes: 3 additions & 3 deletions templates/admin/event/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ul class="dropdown-menu">
{% for type in enum('\\App\\Entity\\EventType').cases %}
<li>
<a class="dropdown-item" href="{{ path('admin_event_create', { type: type.value }) }}">
<a class="dropdown-item" href="{{ path('admin_event_create', {type: type.value}) }}">
{{ type|trans }}
</a>
</li>
Expand Down Expand Up @@ -43,7 +43,7 @@
<td>{{ event.createdAt|format_datetime }}</td>
<td>
{% if is_granted(constant('App\\Admin\\Security\\Permission::EVENT_VIEW_REGISTRATIONS').value, event) %}
<twig:Admin:IconView url="{{ path('admin_event_show', { slug: event.slug }) }}" />
<twig:Admin:IconView url="{{ path('admin_event_show', {slug: event.slug}) }}" />
{% endif %}
</td>
</tr>
Expand Down Expand Up @@ -72,7 +72,7 @@
<td>{{ event.createdAt|format_datetime }}</td>
<td>
{% if is_granted(constant('App\\Admin\\Security\\Permission::EVENT_VIEW_REGISTRATIONS').value, event) %}
<twig:Admin:IconView url="{{ path('admin_event_show', { slug: event.slug }) }}" />
<twig:Admin:IconView url="{{ path('admin_event_show', {slug: event.slug}) }}" />
{% endif %}
</td>
</tr>
Expand Down
Loading

0 comments on commit 0617540

Please sign in to comment.