Upgrade to Twig 3

This commit is contained in:
Jeremy Benoist 2022-12-15 12:32:16 +01:00
parent e62a9d05cc
commit 28abfe264a
No known key found for this signature in database
GPG key ID: 7168D5DD29F38552
10 changed files with 313 additions and 58 deletions

View file

@ -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(),

View file

@ -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

View file

@ -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",

340
composer.lock generated
View file

@ -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",

View file

@ -3,7 +3,7 @@
<i class="grey-text text-darken-4 activator material-icons right">more_vert</i>
{% endif %}
<a href="{{ path('view', {'id': entry.id}) }}" title="{{ entry.title|striptags|e('html_attr') }}" class="card-title dot-ellipsis dot-resize-update">
{{ 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 }}
</a>
<div class="{{ subClass|default('original grey-text') }}">

View file

@ -18,7 +18,7 @@
<i class="card-title activator grey-text text-darken-4 material-icons right">clear</i>
<span class="card-title">
<a href="{{ path('view', {'id': entry.id}) }}" title="{{ entry.title|striptags|e('html_attr') }}">
{{ entry.title|striptags|truncate(80, true, '…')|raw }}
{{ entry.title|striptags|u.truncate(80, '…', false)|raw }}
</a>
</span>

View file

@ -274,7 +274,7 @@
<li>
<i class="material-icons grey-text" title="{{ 'entry.view.provided_by'|trans }}">launch</i>
<a href="{{ entry.originUrl|e }}" target="_blank" rel="noopener" class="tool grey-text">
{{ entry.originUrl|striptags|removeSchemeAndWww|truncate(32) }}
{{ entry.originUrl|striptags|removeSchemeAndWww|u.truncate(32) }}
</a>
</li>
{% endif %}

View file

@ -31,7 +31,7 @@ class WallabagExtension extends AbstractExtension implements GlobalsInterface
$this->rootDir = $rootDir;
}
public function getGlobals()
public function getGlobals(): array
{
return [];
}

View file

@ -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', [

View file

@ -20,10 +20,12 @@
{% for section in sections|craue_sortSections %}
<div id="set-{{ section }}" class="col s12">
{% 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 %}
</div>
{% endfor %}