From 29308110ea6207fb6f1cb006db9ea79f1be68311 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 22 Feb 2022 14:21:06 +0100 Subject: [PATCH] Templating --- .../Phonenumber/Templating.php | 37 ------------------- .../config/services/phonenumber.yaml | 4 -- .../Resources/views/Entity/person.html.twig | 8 ++-- .../Resources/views/Person/banner.html.twig | 8 ++-- .../Person/list_by_phonenumber.html.twig | 4 +- .../Resources/views/Person/view.html.twig | 6 +-- .../views/Entity/thirdparty.html.twig | 4 +- .../Resources/views/ThirdParty/view.html.twig | 4 +- 8 files changed, 17 insertions(+), 58 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/Phonenumber/Templating.php diff --git a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php b/src/Bundle/ChillMainBundle/Phonenumber/Templating.php deleted file mode 100644 index b2fffd9b3..000000000 --- a/src/Bundle/ChillMainBundle/Phonenumber/Templating.php +++ /dev/null @@ -1,37 +0,0 @@ -phonenumberHelper = $phonenumberHelper; - } - - public function formatPhonenumber(string $phonenumber): string - { - return $this->phonenumberHelper->format($phonenumber); - } - - public function getFilters() - { - return [ - new TwigFilter('chill_format_phonenumber', [$this, 'formatPhonenumber']), - ]; - } -} diff --git a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml index 0482da320..f12cc47a3 100644 --- a/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml +++ b/src/Bundle/ChillMainBundle/config/services/phonenumber.yaml @@ -7,10 +7,6 @@ services: Chill\MainBundle\Phonenumber\PhonenumberHelper: ~ - Chill\MainBundle\Phonenumber\Templating: - tags: - - { name: twig.extension } - Chill\MainBundle\Validation\Validator\ValidPhonenumber: tags: - { name: validator.constraint_validator } diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig index e3280d755..e21716d8e 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Entity/person.html.twig @@ -148,14 +148,14 @@ {% endif %}
  • {% if person.mobilenumber %} - - {{ person.mobilenumber|chill_format_phonenumber }} + + {{ person.mobilenumber|phone_number_format('NATIONAL') }} {% else %} {% if person.phonenumber %} - - {{ person.phonenumber|chill_format_phonenumber }} + + {{ person.phonenumber|phone_number_format('NATIONAL') }} {% else %} {{ 'No data given'|trans }} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/banner.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/banner.html.twig index b603dd70c..e7fbc0228 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/banner.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/banner.html.twig @@ -25,15 +25,15 @@ {% if person.phonenumber %} - - {{ person.phonenumber|chill_format_phonenumber }} + + {{ person.phonenumber|phone_number_format('NATIONAL') }} {% endif %} {% if person.mobilenumber %} - - {{ person.mobilenumber|chill_format_phonenumber }} + + {{ person.mobilenumber|phone_number_format('NATIONAL') }} {% endif %} {% if person.email %} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_by_phonenumber.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_by_phonenumber.html.twig index 642225571..83ee9fff9 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/list_by_phonenumber.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/list_by_phonenumber.html.twig @@ -62,12 +62,12 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig index 9bdc3a479..945984380 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Person/view.html.twig @@ -232,14 +232,14 @@ This view should receive those arguments: {%- if chill_person.fields.phonenumber == 'visible' -%}
    {{ 'Phonenumber'|trans }} :
    -
    {% if person.phonenumber is not empty %}
    {{ person.phonenumber|chill_format_phonenumber }}
    {% else %}{{ 'No data given'|trans }}{% endif %}
    +
    {% if person.phonenumber is not empty %}
    {{ person.phonenumber|phone_number_format('NATIONAL') }}
    {% else %}{{ 'No data given'|trans }}{% endif %}
    {% endif %} {%- if chill_person.fields.mobilenumber == 'visible' -%}
    {{ 'Mobilenumber'|trans }} :
    -
    {% if person.mobilenumber is not empty %}{{ person.mobilenumber|chill_format_phonenumber }}{% else %}{{ 'No data given'|trans }}{% endif %}
    +
    {% if person.mobilenumber is not empty %}{{ person.mobilenumber|phone_number_format('NATIONAL') }}{% else %}{{ 'No data given'|trans }}{% endif %}

    {% if person.acceptSMS %}{{ 'Accept short text message'|trans }}{% endif %}

    {% endif %} @@ -250,7 +250,7 @@ This view should receive those arguments:
    {{ 'Others phone numbers'|trans }} :
    {% for el in person.otherPhoneNumbers %} {% if el.phonenumber is not empty %} -
    {% if el.description is not empty %}{{ el.description }} : {% endif %}{{ el.phonenumber|chill_format_phonenumber }}
    +
    {% if el.description is not empty %}{{ el.description }} : {% endif %}{{ el.phonenumber|phone_number_format('NATIONAL') }}
    {% endif %} {% endfor %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/Entity/thirdparty.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/Entity/thirdparty.html.twig index 79aa7be6c..9fb55f71e 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/Entity/thirdparty.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/Entity/thirdparty.html.twig @@ -111,7 +111,7 @@
  • {% if thirdparty.telephone %} - {{ thirdparty.telephone|chill_format_phonenumber }} + {{ thirdparty.telephone|phone_number_format('NATIONAL') }} {% else %} {{ 'thirdparty.No_phonenumber'|trans }} {% endif %} @@ -136,7 +136,7 @@
  • {% if thirdparty.telephone %} - {{ thirdparty.telephone|chill_format_phonenumber }} + {{ thirdparty.telephone|phone_number_format('NATIONAL') }} {% else %} {{ 'thirdparty.No_phonenumber'|trans }} {% endif %} diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig index 824438fa3..9157ff575 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig +++ b/src/Bundle/ChillThirdPartyBundle/Resources/views/ThirdParty/view.html.twig @@ -69,8 +69,8 @@ {% if thirdParty.telephone == null %} {{ 'No phone given'|trans }} {% else %} - - {{ thirdParty.telephone|chill_print_or_message("thirdparty.No_phonenumber") }} + + {{ thirdParty.telephone|phone_number_format('NATIONAL') }} {% endif %}