Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use namespaced Twig #929

Merged
merged 1 commit into from Apr 1, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions Tests/ProfilerTest.php
Expand Up @@ -17,16 +17,16 @@
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
use Symfony\Component\HttpKernel\Profiler\Profile;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Twig_Environment;
use Twig_Loader_Filesystem;
use Twig_RuntimeLoaderInterface;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
use Twig\RuntimeLoader\RuntimeLoaderInterface;

class ProfilerTest extends BaseTestCase
{
/** @var DebugStack */
private $logger;

/** @var Twig_Environment */
/** @var Environment */
private $twig;

/** @var DoctrineDataCollector */
Expand All @@ -40,17 +40,17 @@ public function setUp()
$this->collector = new DoctrineDataCollector($registry);
$this->collector->addLogger('foo', $this->logger);

$twigLoaderFilesystem = new Twig_Loader_Filesystem(__DIR__ . '/../Resources/views/Collector');
$twigLoaderFilesystem = new FilesystemLoader(__DIR__ . '/../Resources/views/Collector');
$twigLoaderFilesystem->addPath(__DIR__ . '/../vendor/symfony/web-profiler-bundle/Resources/views', 'WebProfiler');
$this->twig = new Twig_Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);
$this->twig = new Environment($twigLoaderFilesystem, ['debug' => true, 'strict_variables' => true]);

$this->twig->addExtension(new CodeExtension('', '', ''));
$this->twig->addExtension(new RoutingExtension($this->getMockBuilder(UrlGeneratorInterface::class)->getMock()));
$this->twig->addExtension(new HttpKernelExtension($this->getMockBuilder(FragmentHandler::class)->disableOriginalConstructor()->getMock()));
$this->twig->addExtension(new WebProfilerExtension());
$this->twig->addExtension(new DoctrineExtension());

$loader = $this->getMockBuilder(Twig_RuntimeLoaderInterface::class)->getMock();
$loader = $this->getMockBuilder(RuntimeLoaderInterface::class)->getMock();
$loader->method('load')->willReturn($this->getMockBuilder(HttpKernelRuntime::class)->disableOriginalConstructor()->getMock());
$this->twig->addRuntimeLoader($loader);
}
Expand Down
14 changes: 7 additions & 7 deletions Twig/DoctrineExtension.php
Expand Up @@ -4,13 +4,13 @@

use SqlFormatter;
use Symfony\Component\VarDumper\Cloner\Data;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

/**
* This class contains the needed functions in order to do the query highlighting
*/
class DoctrineExtension extends Twig_Extension
class DoctrineExtension extends AbstractExtension
{
/**
* Number of maximum characters that one single line can hold in the interface
Expand All @@ -22,14 +22,14 @@ class DoctrineExtension extends Twig_Extension
/**
* Define our functions
*
* @return Twig_SimpleFilter[]
* @return TwigFilter[]
*/
public function getFilters()
{
return [
new Twig_SimpleFilter('doctrine_minify_query', [$this, 'minifyQuery'], ['deprecated' => true]),
new Twig_SimpleFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html']]),
new Twig_SimpleFilter('doctrine_replace_query_parameters', [$this, 'replaceQueryParameters']),
new TwigFilter('doctrine_minify_query', [$this, 'minifyQuery'], ['deprecated' => true]),
new TwigFilter('doctrine_pretty_query', [$this, 'formatQuery'], ['is_safe' => ['html']]),
new TwigFilter('doctrine_replace_query_parameters', [$this, 'replaceQueryParameters']),
];
}

Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -40,14 +40,15 @@
"symfony/validator": "^3.4|^4.1",
"symfony/property-info": "^3.4|^4.1",
"symfony/phpunit-bridge": "^4.2",
"twig/twig": "^1.26|^2.0",
"twig/twig": "^1.34|^2.4",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "7.0",
"symfony/web-profiler-bundle": "^3.4|^4.1",
"doctrine/coding-standard": "^5.0"
},
"conflict": {
"doctrine/orm": "<2.6"
"doctrine/orm": "<2.6",
"twig/twig": "<1.34|>=2.0,<2.4"
},
"suggest": {
"symfony/web-profiler-bundle": "To use the data collector.",
Expand Down