mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
removed unneeded abstraction
This commit is contained in:
@@ -403,7 +403,14 @@ class Twig_Environment
|
||||
}
|
||||
|
||||
if (!class_exists($cls, false)) {
|
||||
$content = $this->compileSource($this->getSourceContext($name));
|
||||
$loader = $this->getLoader();
|
||||
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
||||
$source = new Twig_Source($loader->getSource($name), $name);
|
||||
} else {
|
||||
$source = $loader->getSourceContext($name);
|
||||
}
|
||||
|
||||
$content = $this->compileSource($source);
|
||||
|
||||
if ($this->bcWriteCacheFile) {
|
||||
$this->writeCacheFile($key, $content);
|
||||
@@ -750,21 +757,6 @@ class Twig_Environment
|
||||
return $this->loader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source context for the given template name.
|
||||
*
|
||||
* @return Twig_Source
|
||||
*/
|
||||
public function getSourceContext($name)
|
||||
{
|
||||
$loader = $this->getLoader();
|
||||
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
||||
return new Twig_Source($loader->getSource($name), $name);
|
||||
}
|
||||
|
||||
return $loader->getSourceContext($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default template charset.
|
||||
*
|
||||
|
||||
@@ -1489,8 +1489,13 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
||||
*/
|
||||
function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
|
||||
{
|
||||
$loader = $env->getLoader();
|
||||
try {
|
||||
return $env->getSourceContext($name)->getCode();
|
||||
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
||||
return $loader->getSource($name);
|
||||
} else {
|
||||
return $loader->getSourceContext($name)->getCode();
|
||||
}
|
||||
} catch (Twig_Error_Loader $e) {
|
||||
if (!$ignoreMissing) {
|
||||
throw $e;
|
||||
|
||||
@@ -212,7 +212,13 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
|
||||
|
||||
foreach (array_keys($templates) as $name) {
|
||||
echo "Template: $name\n";
|
||||
echo $twig->compile($twig->parse($twig->tokenize($twig->getSourceContext($name), $name)));
|
||||
$loader = $twig->getLoader();
|
||||
if (!$loader instanceof Twig_SourceContextLoaderInterface) {
|
||||
$source = new Twig_Source($loader->getSource($name), $name);
|
||||
} else {
|
||||
$source = $loader->getSourceContext($name);
|
||||
}
|
||||
echo $twig->compile($twig->parse($twig->tokenize($source)));
|
||||
}
|
||||
}
|
||||
$this->assertEquals($expected, $output, $message.' (in '.$file.')');
|
||||
|
||||
Reference in New Issue
Block a user