Augmentation vers version 3.3.0

This commit is contained in:
Gauvain Boiché
2020-03-31 15:31:03 +02:00
parent d926806907
commit a1864c0414
2618 changed files with 406015 additions and 31377 deletions

View File

@@ -19,6 +19,7 @@ use Twig\Environment;
use Twig\Error\Error;
use Twig\Error\LoaderError;
use Twig\Loader\ExistsLoaderInterface;
use Twig\Loader\SourceContextLoaderInterface;
use Twig\Template;
/**
@@ -44,7 +45,7 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface
*
* @throws Error if something went wrong like a thrown exception while rendering the template
*/
public function render($name, array $parameters = array())
public function render($name, array $parameters = [])
{
return $this->load($name)->render($parameters);
}
@@ -56,7 +57,7 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface
*
* @throws Error if something went wrong like a thrown exception while rendering the template
*/
public function stream($name, array $parameters = array())
public function stream($name, array $parameters = [])
{
$this->load($name)->display($parameters);
}
@@ -74,19 +75,24 @@ class TwigEngine implements EngineInterface, StreamingEngineInterface
$loader = $this->environment->getLoader();
if ($loader instanceof ExistsLoaderInterface || method_exists($loader, 'exists')) {
return $loader->exists((string) $name);
}
if (1 === Environment::MAJOR_VERSION && !$loader instanceof ExistsLoaderInterface) {
try {
// cast possible TemplateReferenceInterface to string because the
// EngineInterface supports them but LoaderInterface does not
if ($loader instanceof SourceContextLoaderInterface) {
$loader->getSourceContext((string) $name);
} else {
$loader->getSource((string) $name);
}
return true;
} catch (LoaderError $e) {
}
try {
// cast possible TemplateReferenceInterface to string because the
// EngineInterface supports them but LoaderInterface does not
$loader->getSourceContext((string) $name)->getCode();
} catch (LoaderError $e) {
return false;
}
return true;
return $loader->exists((string) $name);
}
/**