diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index f912fe3a7..5a8c6b23a 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -13,6 +13,9 @@ use App\Utils\Markdown; use Symfony\Component\Intl\Intl; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; /** * This Twig extension adds a new 'md2html' filter to easily transform Markdown @@ -27,7 +30,7 @@ * @author Javier Eguiluz * @author Julien ITARD */ -class AppExtension extends \Twig_Extension +class AppExtension extends AbstractExtension { private $parser; private $localeCodes; @@ -45,7 +48,7 @@ public function __construct(Markdown $parser, $locales) public function getFilters() { return [ - new \Twig_SimpleFilter('md2html', [$this, 'markdownToHtml'], ['is_safe' => ['html']]), + new TwigFilter('md2html', [$this, 'markdownToHtml'], ['is_safe' => ['html']]), ]; } @@ -55,7 +58,7 @@ public function getFilters() public function getFunctions() { return [ - new \Twig_SimpleFunction('locales', [$this, 'getLocales']), + new TwigFunction('locales', [$this, 'getLocales']), ]; } diff --git a/src/Twig/SourceCodeExtension.php b/src/Twig/SourceCodeExtension.php index 324150ce9..27c780944 100644 --- a/src/Twig/SourceCodeExtension.php +++ b/src/Twig/SourceCodeExtension.php @@ -11,6 +11,11 @@ namespace App\Twig; +use Twig\Environment; +use Twig\Extension\AbstractExtension; +use Twig\Template; +use Twig\TwigFunction; + /** * CAUTION: this is an extremely advanced Twig extension. It's used to get the * source code of the controller and the template used to render the current @@ -20,7 +25,7 @@ * @author Ryan Weaver * @author Javier Eguiluz */ -class SourceCodeExtension extends \Twig_Extension +class SourceCodeExtension extends AbstractExtension { private $controller; @@ -35,11 +40,11 @@ public function setController($controller) public function getFunctions() { return [ - new \Twig_SimpleFunction('show_source_code', [$this, 'showSourceCode'], ['is_safe' => ['html'], 'needs_environment' => true]), + new TwigFunction('show_source_code', [$this, 'showSourceCode'], ['is_safe' => ['html'], 'needs_environment' => true]), ]; } - public function showSourceCode(\Twig_Environment $twig, $template) + public function showSourceCode(Environment $twig, $template) { return $twig->render('debug/source_code.html.twig', [ 'controller' => $this->getController(), @@ -91,7 +96,7 @@ private function getCallableReflector($callable) return new \ReflectionFunction($callable); } - private function getTemplateSource(\Twig_Template $template) + private function getTemplateSource(Template $template) { $templateSource = $template->getSourceContext();