From cae1295c227f0be20f9b290cb070e4d6e4bcaed6 Mon Sep 17 00:00:00 2001 From: Awilum Date: Wed, 5 Aug 2020 16:42:10 +0300 Subject: [PATCH] Twig 1.1.1 --- CHANGELOG.md | 7 +++++++ plugin.yaml | 2 +- twig/ArraysTwigExtension.php | 8 ++++---- twig/CacheTwigExtension.php | 8 ++++---- twig/CollectionTwigExtension.php | 8 +++----- twig/CsrfTwigExtension.php | 11 +++++------ twig/EmitterTwigExtension.php | 8 ++++---- twig/EntriesTwigExtension.php | 8 ++++---- twig/FilesystemTwigExtension.php | 15 +++++++-------- twig/FlashTwigExtension.php | 7 +++---- twig/GlobalVarsTwigExtension.php | 8 ++++---- twig/I18nTwigExtension.php | 12 +++++------- twig/JsonTwigExtension.php | 14 ++++++-------- twig/MarkdownTwigExtension.php | 7 +++---- twig/RegistryTwigExtension.php | 8 ++++---- twig/ShortcodeTwigExtension.php | 7 +++---- twig/UrlTwigExtension.php | 7 +++---- twig/YamlTwigExtension.php | 14 ++++++-------- 18 files changed, 76 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a58a098..de36f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ + +# [1.1.1](https://github.com/flextype-plugins/twig/compare/v1.1.0...v1.1.1) (2020-08-05) + +### Bug Fixes + +* **core** fixes for new Twig 3 + # [1.1.0](https://github.com/flextype-plugins/twig/compare/v1.0.7...v1.1.0) (2020-08-05) diff --git a/plugin.yaml b/plugin.yaml index cc99a91..2144735 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: Twig -version: 1.2.0 +version: 1.1.1 description: Twig plugin to present Twig template engine for Flextype. icon: fas fa-palette author: diff --git a/twig/ArraysTwigExtension.php b/twig/ArraysTwigExtension.php index d95b9d2..b8ea34d 100644 --- a/twig/ArraysTwigExtension.php +++ b/twig/ArraysTwigExtension.php @@ -9,11 +9,11 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; use Flextype\Component\Arrays\Arrays; -class ArraysTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class ArraysTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -31,7 +31,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'arrays' => new ArraysTwig($this->flextype), diff --git a/twig/CacheTwigExtension.php b/twig/CacheTwigExtension.php index 4fdad31..bd0dc92 100644 --- a/twig/CacheTwigExtension.php +++ b/twig/CacheTwigExtension.php @@ -9,10 +9,10 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; -class CacheTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class CacheTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -30,7 +30,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'cache' => $this->flextype['cache'], diff --git a/twig/CollectionTwigExtension.php b/twig/CollectionTwigExtension.php index 6c8a598..b408bae 100644 --- a/twig/CollectionTwigExtension.php +++ b/twig/CollectionTwigExtension.php @@ -9,11 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFunction; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; -class CollectionTwigExtension extends Twig_Extension +class CollectionTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -36,7 +34,7 @@ public function __construct($flextype) public function getFunctions() : array { return [ - new Twig_SimpleFunction('collect', [$this, 'collect']), + new \Twig\TwigFunction('collect', [$this, 'collect']), ]; } diff --git a/twig/CsrfTwigExtension.php b/twig/CsrfTwigExtension.php index 2794876..cd035dd 100644 --- a/twig/CsrfTwigExtension.php +++ b/twig/CsrfTwigExtension.php @@ -9,11 +9,10 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; -class CsrfTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class CsrfTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -31,7 +30,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { // CSRF token name and value $csrfNameKey = $this->flextype->csrf->getTokenNameKey(); @@ -64,7 +63,7 @@ public function getName() public function getFunctions() : array { return [ - new Twig_SimpleFunction('csrf', [$this, 'csrf'], ['is_safe' => ['html']]), + new \Twig\TwigFunction('csrf', [$this, 'csrf'], ['is_safe' => ['html']]), ]; } diff --git a/twig/EmitterTwigExtension.php b/twig/EmitterTwigExtension.php index 6843f97..d0cde6d 100644 --- a/twig/EmitterTwigExtension.php +++ b/twig/EmitterTwigExtension.php @@ -9,10 +9,10 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; -class EmitterTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class EmitterTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -30,7 +30,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'emitter' => new EmitterTwig($this->flextype), diff --git a/twig/EntriesTwigExtension.php b/twig/EntriesTwigExtension.php index 5ffd4ad..77e8622 100644 --- a/twig/EntriesTwigExtension.php +++ b/twig/EntriesTwigExtension.php @@ -9,10 +9,10 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; -class EntriesTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class EntriesTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -30,7 +30,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'entries' => new EntriesTwig($this->flextype), diff --git a/twig/FilesystemTwigExtension.php b/twig/FilesystemTwigExtension.php index a8b220a..128d6cf 100644 --- a/twig/FilesystemTwigExtension.php +++ b/twig/FilesystemTwigExtension.php @@ -10,13 +10,12 @@ namespace Flextype\Plugin\Twig\Twig; use Flextype\Component\Filesystem\Filesystem; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; use function basename; use function strrchr; use function substr; -class FilesystemTwigExtension extends Twig_Extension +class FilesystemTwigExtension extends AbstractExtension { /** * Callback for twig. @@ -26,11 +25,11 @@ class FilesystemTwigExtension extends Twig_Extension public function getFunctions() : array { return [ - new Twig_SimpleFunction('filesystem_list_contents', [$this, 'list_contents']), - new Twig_SimpleFunction('filesystem_has', [$this, 'has']), - new Twig_SimpleFunction('filesystem_read', [$this, 'read']), - new Twig_SimpleFunction('filesystem_ext', [$this, 'ext']), - new Twig_SimpleFunction('filesystem_basename', [$this, 'basename']), + new \Twig\TwigFunction('filesystem_list_contents', [$this, 'list_contents']), + new \Twig\TwigFunction('filesystem_has', [$this, 'has']), + new \Twig\TwigFunction('filesystem_read', [$this, 'read']), + new \Twig\TwigFunction('filesystem_ext', [$this, 'ext']), + new \Twig\TwigFunction('filesystem_basename', [$this, 'basename']), ]; } diff --git a/twig/FlashTwigExtension.php b/twig/FlashTwigExtension.php index 73afb5d..ccf81e7 100644 --- a/twig/FlashTwigExtension.php +++ b/twig/FlashTwigExtension.php @@ -9,10 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; -class FlashTwigExtension extends Twig_Extension +class FlashTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -35,7 +34,7 @@ public function __construct($flextype) public function getFunctions() : array { return [ - new Twig_SimpleFunction('flash', [$this, 'getMessages']), + new \Twig\TwigFunction('flash', [$this, 'getMessages']), ]; } diff --git a/twig/GlobalVarsTwigExtension.php b/twig/GlobalVarsTwigExtension.php index b67f785..5597a3c 100644 --- a/twig/GlobalVarsTwigExtension.php +++ b/twig/GlobalVarsTwigExtension.php @@ -9,11 +9,11 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; use const PHP_VERSION; -class GlobalVarsTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class GlobalVarsTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -31,7 +31,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'PATH_PROJECT' => PATH['project'], diff --git a/twig/I18nTwigExtension.php b/twig/I18nTwigExtension.php index 48c01f6..68b92a1 100644 --- a/twig/I18nTwigExtension.php +++ b/twig/I18nTwigExtension.php @@ -10,11 +10,9 @@ namespace Flextype\Plugin\Twig\Twig; use Flextype\Component\I18n\I18n; -use Twig_Extension; -use Twig_SimpleFilter; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; -class I18nTwigExtension extends Twig_Extension +class I18nTwigExtension extends AbstractExtension { /** * Returns a list of functions to add to the existing list. @@ -24,8 +22,8 @@ class I18nTwigExtension extends Twig_Extension public function getFunctions() : array { return [ - new Twig_SimpleFunction('tr', [$this, 'tr']), - new Twig_SimpleFunction('__', [$this, 'tr']), + new \Twig\TwigFunction('tr', [$this, 'tr']), + new \Twig\TwigFunction('__', [$this, 'tr']), ]; } @@ -37,7 +35,7 @@ public function getFunctions() : array public function getFilters() : array { return [ - new Twig_SimpleFilter('tr', [$this, 'tr']) + new \Twig\TwigFilter('tr', [$this, 'tr']) ]; } diff --git a/twig/JsonTwigExtension.php b/twig/JsonTwigExtension.php index fb8b857..bab95a6 100644 --- a/twig/JsonTwigExtension.php +++ b/twig/JsonTwigExtension.php @@ -9,11 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFilter; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; -class JsonTwigExtension extends Twig_Extension +class JsonTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -36,8 +34,8 @@ public function __construct($flextype) public function getFunctions() : array { return [ - new Twig_SimpleFunction('json_decode', [$this, 'decode']), - new Twig_SimpleFunction('json_encode', [$this, 'encode']), + new \Twig\TwigFunction('json_decode', [$this, 'decode']), + new \Twig\TwigFunction('json_encode', [$this, 'encode']), ]; } @@ -49,8 +47,8 @@ public function getFunctions() : array public function getFilters() : array { return [ - new Twig_SimpleFilter('json_decode', [$this, 'decode']), - new Twig_SimpleFilter('json_encode', [$this, 'encode']), + new \Twig\TwigFilter('json_decode', [$this, 'decode']), + new \Twig\TwigFilter('json_encode', [$this, 'encode']), ]; } diff --git a/twig/MarkdownTwigExtension.php b/twig/MarkdownTwigExtension.php index 3c67fb7..8622d1f 100644 --- a/twig/MarkdownTwigExtension.php +++ b/twig/MarkdownTwigExtension.php @@ -9,10 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFilter; +use Twig\Extension\AbstractExtension; -class MarkdownTwigExtension extends Twig_Extension +class MarkdownTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -35,7 +34,7 @@ public function __construct($flextype) public function getFilters() : array { return [ - new Twig_SimpleFilter('markdown', [$this, 'markdown']), + new \Twig\TwigFilter('markdown', [$this, 'markdown']), ]; } diff --git a/twig/RegistryTwigExtension.php b/twig/RegistryTwigExtension.php index d349373..3fc591a 100644 --- a/twig/RegistryTwigExtension.php +++ b/twig/RegistryTwigExtension.php @@ -9,10 +9,10 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_Extension_GlobalsInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; -class RegistryTwigExtension extends Twig_Extension implements Twig_Extension_GlobalsInterface +class RegistryTwigExtension extends AbstractExtension implements GlobalsInterface { /** * Flextype Dependency Container @@ -30,7 +30,7 @@ public function __construct($flextype) /** * Register Global variables in an extension */ - public function getGlobals() + public function getGlobals() : array { return [ 'registry' => new RegistryTwig($this->flextype), diff --git a/twig/ShortcodeTwigExtension.php b/twig/ShortcodeTwigExtension.php index b32abcd..ff43ccc 100644 --- a/twig/ShortcodeTwigExtension.php +++ b/twig/ShortcodeTwigExtension.php @@ -9,10 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFilter; +use Twig\Extension\AbstractExtension; -class ShortcodeTwigExtension extends Twig_Extension +class ShortcodeTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -35,7 +34,7 @@ public function __construct($flextype) public function getFilters() : array { return [ - new Twig_SimpleFilter('shortcode', [$this, 'shortcode']), + new \Twig\TwigFilter('shortcode', [$this, 'shortcode']), ]; } diff --git a/twig/UrlTwigExtension.php b/twig/UrlTwigExtension.php index 29c64d0..87d4da0 100644 --- a/twig/UrlTwigExtension.php +++ b/twig/UrlTwigExtension.php @@ -9,12 +9,11 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; use Slim\Http\Environment; use Slim\Http\Uri; -class UrlTwigExtension extends Twig_Extension +class UrlTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -37,7 +36,7 @@ public function __construct($flextype) public function getFunctions() : array { return [ - new Twig_SimpleFunction('url', [$this, 'url'], ['is_safe' => ['html']]) + new \Twig\TwigFunction('url', [$this, 'url'], ['is_safe' => ['html']]) ]; } diff --git a/twig/YamlTwigExtension.php b/twig/YamlTwigExtension.php index 74bbca3..702b53c 100644 --- a/twig/YamlTwigExtension.php +++ b/twig/YamlTwigExtension.php @@ -9,11 +9,9 @@ namespace Flextype\Plugin\Twig\Twig; -use Twig_Extension; -use Twig_SimpleFilter; -use Twig_SimpleFunction; +use Twig\Extension\AbstractExtension; -class YamlTwigExtension extends Twig_Extension +class YamlTwigExtension extends AbstractExtension { /** * Flextype Dependency Container @@ -36,8 +34,8 @@ public function __construct($flextype) public function getFunctions() : array { return [ - new Twig_SimpleFunction('yaml_decode', [$this, 'decode']), - new Twig_SimpleFunction('yaml_encode', [$this, 'encode']), + new \Twig\TwigFunction('yaml_decode', [$this, 'decode']), + new \Twig\TwigFunction('yaml_encode', [$this, 'encode']), ]; } @@ -49,8 +47,8 @@ public function getFunctions() : array public function getFilters() : array { return [ - new Twig_SimpleFilter('yaml_decode', [$this, 'decode']), - new Twig_SimpleFilter('yaml_encode', [$this, 'encode']), + new \Twig\TwigFilter('yaml_decode', [$this, 'decode']), + new \Twig\TwigFilter('yaml_encode', [$this, 'encode']), ]; }