Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -27,7 +30,7 @@
* @author Javier Eguiluz <[email protected]>
* @author Julien ITARD <[email protected]>
*/
class AppExtension extends \Twig_Extension
class AppExtension extends AbstractExtension
{
private $parser;
private $localeCodes;
Expand All @@ -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']]),
];
}

Expand All @@ -55,7 +58,7 @@ public function getFilters()
public function getFunctions()
{
return [
new \Twig_SimpleFunction('locales', [$this, 'getLocales']),
new TwigFunction('locales', [$this, 'getLocales']),
];
}

Expand Down
13 changes: 9 additions & 4 deletions src/Twig/SourceCodeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -20,7 +25,7 @@
* @author Ryan Weaver <[email protected]>
* @author Javier Eguiluz <[email protected]>
*/
class SourceCodeExtension extends \Twig_Extension
class SourceCodeExtension extends AbstractExtension
{
private $controller;

Expand All @@ -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(),
Expand Down Expand Up @@ -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();

Expand Down