[Twig] Remove dead code
This commit is contained in:
parent
8535416d25
commit
786d136b5e
@ -34,9 +34,7 @@ class FormThemeTokenParserTest extends TestCase
|
|||||||
$stream = $env->tokenize($source);
|
$stream = $env->tokenize($source);
|
||||||
$parser = new Parser($env);
|
$parser = new Parser($env);
|
||||||
|
|
||||||
if (method_exists($expected, 'setSourceContext')) {
|
$expected->setSourceContext($source);
|
||||||
$expected->setSourceContext($source);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
||||||
}
|
}
|
||||||
|
@ -89,13 +89,10 @@ class TwigExtractorTest extends TestCase
|
|||||||
try {
|
try {
|
||||||
$extractor->extract($resources, new MessageCatalogue('en'));
|
$extractor->extract($resources, new MessageCatalogue('en'));
|
||||||
} catch (Error $e) {
|
} catch (Error $e) {
|
||||||
if (method_exists($e, 'getSourceContext')) {
|
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
||||||
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
$this->assertSame(1, $e->getLine());
|
||||||
$this->assertSame(1, $e->getLine());
|
$this->assertSame('Unclosed "block".', $e->getMessage());
|
||||||
$this->assertSame('Unclosed "block".', $e->getMessage());
|
|
||||||
} else {
|
|
||||||
$this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/');
|
|
||||||
}
|
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,11 +61,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
|||||||
if ($file instanceof \SplFileInfo) {
|
if ($file instanceof \SplFileInfo) {
|
||||||
$path = $file->getRealPath() ?: $file->getPathname();
|
$path = $file->getRealPath() ?: $file->getPathname();
|
||||||
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
|
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
|
||||||
if (method_exists($e, 'setSourceContext')) {
|
$e->setSourceContext(new Source('', $name, $path));
|
||||||
$e->setSourceContext(new Source('', $name, $path));
|
|
||||||
} else {
|
|
||||||
$e->setTemplateName($name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw $e;
|
throw $e;
|
||||||
|
@ -13,7 +13,6 @@ namespace Symfony\Bundle\TwigBundle;
|
|||||||
|
|
||||||
use Symfony\Bridge\Twig\TwigEngine as BaseEngine;
|
use Symfony\Bridge\Twig\TwigEngine as BaseEngine;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
|
||||||
use Symfony\Component\Config\FileLocatorInterface;
|
use Symfony\Component\Config\FileLocatorInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||||
@ -36,28 +35,6 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
|||||||
$this->locator = $locator;
|
$this->locator = $locator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function render($name, array $parameters = [])
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
return parent::render($name, $parameters);
|
|
||||||
} catch (Error $e) {
|
|
||||||
if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) {
|
|
||||||
try {
|
|
||||||
// try to get the real name of the template where the error occurred
|
|
||||||
$name = $e->getTemplateName();
|
|
||||||
$path = (string) $this->locator->locate($this->parser->parse($name));
|
|
||||||
$e->setTemplateName($path);
|
|
||||||
} catch (\Exception $e2) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user