Twig_* Methods / Classes Deprecated
Closed this issue · 1 comments
The latest update of twig has completely removed the ability to use the Twig_Extension, Twig_Filter and Twig_SimpleFunction. I'm unable to submit a branch / PR to fix this so here is the fix. Can this be put in?
``<?php
/*
- UrlEncryptorExtension file.
- (c) Ala Eddine Khefifi alakhefifi@gmail.com
- For the full copyright and license information, please view the LICENSE
- file that was distributed with this source code.
*/
namespace Nzo\UrlEncryptorBundle\Twig;
use Nzo\UrlEncryptorBundle\UrlEncryptor\UrlEncryptor;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use Twig\TwigFunction;
/**
-
Class UrlEncryptorExtension
-
@Package Nzo\UrlEncryptorBundle\Twig
/
class UrlEncryptorExtension extends AbstractExtension
{
/*- @var UrlEncryptor
*/
private $urlencryptor;
/**
- UrlEncryptorExtension constructor.
- @param UrlEncryptor $urlencryptor
*/
public function __construct(UrlEncryptor $urlencryptor)
{
$this->urlencryptor = $urlencryptor;
}
public function getFilters()
{
return array(
new TwigFilter('urlencrypt', array($this, 'urlencryptFilter')),
new TwigFilter('urldecrypt', array($this, 'urldecryptFilter')),
);
}public function getFunctions()
{
return array(
new TwigFunction('nzoEncrypt', array($this, 'nzoEncryptFunction')),
new TwigFunction('nzoDecrypt', array($this, 'nzoDecryptFunction')),
);
}/**
- @param string $key
- @return string
*/
public function urlencryptFilter($key)
{
return $this->urlencryptor->encrypt($key);
}
/**
- @param string $key
- @return string
*/
public function urldecryptFilter($key)
{
return $this->urlencryptor->decrypt($key);
}
/**
- @param string $key
- @return string
*/
public function nzoEncryptFunction($key)
{
return $this->urlencryptor->encrypt($key);
}
/**
- @param string $key
- @return string
*/
public function nzoDecryptFunction($key)
{
return $this->urlencryptor->decrypt($key);
}
public function getName()
{
return 'nzo_urlencryptor_extension';
}
}
`` - @var UrlEncryptor
Fixed in : https://github.com/nayzo/NzoUrlEncryptorBundle/releases/tag/v4.3.0
Thank you 👍