From 28abfe264a5e421ec5a830a32c05d307e9268ca1 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 15 Dec 2022 12:32:16 +0100 Subject: [PATCH] Upgrade to Twig 3 --- app/AppKernel.php | 1 + app/config/services.yml | 3 - composer.json | 7 +- composer.lock | 340 +++++++++++++++--- .../views/Entry/Card/_content.html.twig | 2 +- .../views/Entry/_card_preview.html.twig | 2 +- .../Resources/views/Entry/entry.html.twig | 2 +- .../CoreBundle/Twig/WallabagExtension.php | 2 +- .../UserBundle/Mailer/AuthCodeMailer.php | 2 +- .../Settings/modify.html.twig | 10 +- 10 files changed, 313 insertions(+), 58 deletions(-) diff --git a/app/AppKernel.php b/app/AppKernel.php index 63d74e915..a7b4f9b80 100644 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -35,6 +35,7 @@ class AppKernel extends Kernel new OldSound\RabbitMqBundle\OldSoundRabbitMqBundle(), new Http\HttplugBundle\HttplugBundle(), new Sentry\SentryBundle\SentryBundle(), + new Twig\Extra\TwigExtraBundle\TwigExtraBundle(), // wallabag bundles new Wallabag\CoreBundle\WallabagCoreBundle(), diff --git a/app/config/services.yml b/app/config/services.yml index 1125e53b9..a3f5bd7eb 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -96,9 +96,6 @@ services: FOS\UserBundle\Model\UserManagerInterface: alias: fos_user.user_manager - Twig_Extensions_Extension_Text: - class: Twig_Extensions_Extension_Text - MatomoTwigExtension\MatomoTwigExtension: public: false diff --git a/composer.json b/composer.json index 394089fba..167fe91c4 100644 --- a/composer.json +++ b/composer.json @@ -82,8 +82,8 @@ "kphoen/rulerz-bundle": "~0.13", "laminas/laminas-code": "^4.7", "laminas/laminas-diactoros": "^2.3", - "lexik/form-filter-bundle": "^6.1.1", "lcobucci/jwt": "~4.1.5", + "lexik/form-filter-bundle": "^6.1.1", "mgargano/simplehtmldom": "~1.5", "mnapoli/piwik-twig-extension": "^3.0", "nelmio/api-doc-bundle": "^3.0", @@ -118,8 +118,9 @@ "symfony/swiftmailer-bundle": "^3.2", "symfony/symfony": "^4.0", "tecnickcom/tcpdf": "^6.3.0", - "twig/extensions": "^1.5", - "twig/twig": "^2.15", + "twig/extra-bundle": "^3.4", + "twig/string-extra": "^3.4", + "twig/twig": "^3.4.3", "wallabag/php-mobi": "~1.0", "wallabag/phpepub": "^4.0.10", "willdurand/hateoas": "^3.8", diff --git a/composer.lock b/composer.lock index 41d046ddf..c7cdc247f 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "79a9a30daade8ca4b6a9592de40f8c76", + "content-hash": "9cb9f1c17c18fcc6322d0e9e9239c7cb", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -10034,6 +10034,87 @@ ], "time": "2022-11-03T14:55:06+00:00" }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, { "name": "symfony/polyfill-intl-icu", "version": "v1.27.0", @@ -10774,6 +10855,92 @@ ], "time": "2022-11-03T14:55:06+00:00" }, + { + "name": "symfony/string", + "version": "v5.4.15", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "reference": "571334ce9f687e3e6af72db4d3b2a9431e4fd9ed", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "~1.15" + }, + "conflict": { + "symfony/translation-contracts": ">=3.0" + }, + "require-dev": { + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/http-client": "^4.4|^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v5.4.15" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-10-05T15:16:54+00:00" + }, { "name": "symfony/swiftmailer-bundle", "version": "v3.5.4", @@ -11325,42 +11492,49 @@ "time": "2016-11-16T10:37:54+00:00" }, { - "name": "twig/extensions", - "version": "v1.5.4", + "name": "twig/extra-bundle", + "version": "v3.4.0", "source": { "type": "git", - "url": "https://github.com/twigphp/Twig-extensions.git", - "reference": "57873c8b0c1be51caa47df2cdb824490beb16202" + "url": "https://github.com/twigphp/twig-extra-bundle.git", + "reference": "2e58256b0e9fe52f30149347c0547e4633304765" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig-extensions/zipball/57873c8b0c1be51caa47df2cdb824490beb16202", - "reference": "57873c8b0c1be51caa47df2cdb824490beb16202", + "url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/2e58256b0e9fe52f30149347c0547e4633304765", + "reference": "2e58256b0e9fe52f30149347c0547e4633304765", "shasum": "" }, "require": { - "twig/twig": "^1.27|^2.0" + "php": ">=7.2.5", + "symfony/framework-bundle": "^4.4|^5.0|^6.0", + "symfony/twig-bundle": "^4.4|^5.0|^6.0", + "twig/twig": "^2.7|^3.0" }, "require-dev": { - "symfony/phpunit-bridge": "^3.4", - "symfony/translation": "^2.7|^3.4" + "league/commonmark": "^1.0|^2.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", + "twig/cache-extra": "^3.0", + "twig/cssinliner-extra": "^2.12|^3.0", + "twig/html-extra": "^2.12|^3.0", + "twig/inky-extra": "^2.12|^3.0", + "twig/intl-extra": "^2.12|^3.0", + "twig/markdown-extra": "^2.12|^3.0", + "twig/string-extra": "^2.12|^3.0" }, - "suggest": { - "symfony/translation": "Allow the time_diff output to be translated" - }, - "type": "library", + "type": "symfony-bundle", "extra": { "branch-alias": { - "dev-master": "1.5-dev" + "dev-master": "3.2-dev" } }, "autoload": { - "psr-0": { - "Twig_Extensions_": "lib/" - }, "psr-4": { - "Twig\\Extensions\\": "src/" - } + "Twig\\Extra\\TwigExtraBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -11369,40 +11543,123 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" } ], - "description": "Common additional features for Twig that do not directly belong in core", + "description": "A Symfony bundle for extra Twig extensions", + "homepage": "https://twig.symfony.com", "keywords": [ - "i18n", - "text" + "bundle", + "extra", + "twig" ], "support": { - "issues": "https://github.com/twigphp/Twig-extensions/issues", - "source": "https://github.com/twigphp/Twig-extensions/tree/master" + "source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.4.0" }, - "abandoned": true, - "time": "2018-12-05T18:34:18+00:00" + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2022-01-04T13:58:53+00:00" }, { - "name": "twig/twig", - "version": "v2.15.3", + "name": "twig/string-extra", + "version": "v3.4.0", "source": { "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "ab402673db8746cb3a4c46f3869d6253699f614a" + "url": "https://github.com/twigphp/string-extra.git", + "reference": "03608ae2e9c270a961e8cf1b75751e8635ad3e3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/ab402673db8746cb3a4c46f3869d6253699f614a", - "reference": "ab402673db8746cb3a4c46f3869d6253699f614a", + "url": "https://api.github.com/repos/twigphp/string-extra/zipball/03608ae2e9c270a961e8cf1b75751e8635ad3e3c", + "reference": "03608ae2e9c270a961e8cf1b75751e8635ad3e3c", "shasum": "" }, "require": { - "php": ">=7.1.3", + "php": ">=7.2.5", + "symfony/string": "^5.0|^6.0", + "symfony/translation-contracts": "^1.1|^2|^3", + "twig/twig": "^2.7|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Twig\\Extra\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + } + ], + "description": "A Twig extension for Symfony String", + "homepage": "https://twig.symfony.com", + "keywords": [ + "html", + "string", + "twig", + "unicode" + ], + "support": { + "source": "https://github.com/twigphp/string-extra/tree/v3.4.0" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2022-01-02T10:02:25+00:00" + }, + { + "name": "twig/twig", + "version": "v3.4.3", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/c38fd6b0b7f370c198db91ffd02e23b517426b58", + "reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "^1.3", - "symfony/polyfill-php72": "^1.8" + "symfony/polyfill-mbstring": "^1.3" }, "require-dev": { "psr/container": "^1.0", @@ -11411,13 +11668,10 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.15-dev" + "dev-master": "3.4-dev" } }, "autoload": { - "psr-0": { - "Twig_": "lib/" - }, "psr-4": { "Twig\\": "src/" } @@ -11450,7 +11704,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v2.15.3" + "source": "https://github.com/twigphp/Twig/tree/v3.4.3" }, "funding": [ { @@ -11462,7 +11716,7 @@ "type": "tidelift" } ], - "time": "2022-09-28T08:40:08+00:00" + "time": "2022-09-28T08:42:51+00:00" }, { "name": "wallabag/php-mobi", diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/Card/_content.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/Card/_content.html.twig index f1038a9ae..34bf483d7 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/Card/_content.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/Card/_content.html.twig @@ -3,7 +3,7 @@ more_vert {% endif %} - {{ entry.title|striptags|truncate(80, true, '…')|default('entry.default_title'|trans)|raw }} + {{ entry.title|striptags|u.truncate(80, '…', false)|default('entry.default_title'|trans)|raw }}
diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/_card_preview.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/_card_preview.html.twig index 4ab5e44ea..efd8d03e9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/_card_preview.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/_card_preview.html.twig @@ -18,7 +18,7 @@ clear - {{ entry.title|striptags|truncate(80, true, '…')|raw }} + {{ entry.title|striptags|u.truncate(80, '…', false)|raw }} diff --git a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig index 071ebb251..ee03e131c 100644 --- a/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/Entry/entry.html.twig @@ -274,7 +274,7 @@
  • launch - {{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }} + {{ entry.originUrl|striptags|removeSchemeAndWww|u.truncate(32) }}
  • {% endif %} diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index ca0cc9a55..69011ffa0 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -31,7 +31,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface $this->rootDir = $rootDir; } - public function getGlobals() + public function getGlobals(): array { return []; } diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php index 829e56e5e..d86302379 100644 --- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php +++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php @@ -77,7 +77,7 @@ class AuthCodeMailer implements AuthCodeMailerInterface */ public function sendAuthCode(TwoFactorInterface $user): void { - $template = $this->twig->loadTemplate('@WallabagUser/TwoFactor/email_auth_code.html.twig'); + $template = $this->twig->load('@WallabagUser/TwoFactor/email_auth_code.html.twig'); $subject = $template->renderBlock('subject', []); $bodyHtml = $template->renderBlock('body_html', [ diff --git a/templates/bundles/CraueConfigBundle/Settings/modify.html.twig b/templates/bundles/CraueConfigBundle/Settings/modify.html.twig index 4e61ec4cd..b4f8a32d3 100644 --- a/templates/bundles/CraueConfigBundle/Settings/modify.html.twig +++ b/templates/bundles/CraueConfigBundle/Settings/modify.html.twig @@ -20,10 +20,12 @@ {% for section in sections|craue_sortSections %}
    - {% for setting in form.settings if setting.vars.value.section == section %} - {{ form_row(setting.value, { - 'label': setting.vars.value.name|trans({}, 'CraueConfigBundle'), - }) }} + {% for setting in form.settings %} + {% if setting.vars.value.section == section %} + {{ form_row(setting.value, { + 'label': setting.vars.value.name|trans({}, 'CraueConfigBundle'), + }) }} + {% endif %} {% endfor %}
    {% endfor %}