[feature/twig] Fixed tabs in environment.php

PHPBB3-11598
This commit is contained in:
Nathaniel Guse 2013-07-01 21:21:37 -05:00
parent 16ebf14653
commit e0f5e23032

View file

@ -29,7 +29,7 @@ class phpbb_template_twig_environment extends Twig_Environment
/** @var array **/ /** @var array **/
protected $namespaceLookUpOrder = array('__main__'); protected $namespaceLookUpOrder = array('__main__');
public function __construct($phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array()) public function __construct($phpbb_config, $phpbb_extensions, $phpbb_root_path, Twig_LoaderInterface $loader = null, $options = array())
{ {
$this->phpbb_config = $phpbb_config; $this->phpbb_config = $phpbb_config;
$this->phpbb_extensions = $phpbb_extensions; $this->phpbb_extensions = $phpbb_extensions;
@ -38,19 +38,20 @@ class phpbb_template_twig_environment extends Twig_Environment
return parent::__construct($loader, $options); return parent::__construct($loader, $options);
} }
/** /**
* Gets the cache filename for a given template. * Gets the cache filename for a given template.
* *
* @param string $name The template name * @param string $name The template name
* *
* @return string The cache file name * @return string The cache file name
*/ */
public function ignoregetCacheFilename($name) public function ignoregetCacheFilename($name)
{ {
if (false === $this->cache) { if (false === $this->cache)
return false; {
} return false;
// @todo }
// @todo
$file_path = $this->getLoader()->getCacheKey($name); $file_path = $this->getLoader()->getCacheKey($name);
foreach ($this->getLoader()->getNamespaces() as $namespace) foreach ($this->getLoader()->getNamespaces() as $namespace)
{ {
@ -64,9 +65,9 @@ class phpbb_template_twig_environment extends Twig_Environment
} }
// We probably should never get here under normal circumstances // We probably should never get here under normal circumstances
return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '.php'; return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '.php';
return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '_' . md5($this->getLoader()->getCacheKey($name)) . '.php'; return $this->getCache() . '/' . preg_replace('#[^a-zA-Z0-9_/]#', '_', $name) . '_' . md5($this->getLoader()->getCacheKey($name)) . '.php';
} }
/** /**
* Get the list of enabled phpBB extensions * Get the list of enabled phpBB extensions
@ -112,7 +113,7 @@ class phpbb_template_twig_environment extends Twig_Environment
* Set the namespace look up order to load templates from * Set the namespace look up order to load templates from
* *
* @param array $namespace * @param array $namespace
* @return Twig_Environment * @return Twig_Environment
*/ */
public function setNamespaceLookUpOrder($namespace) public function setNamespaceLookUpOrder($namespace)
{ {
@ -121,28 +122,28 @@ class phpbb_template_twig_environment extends Twig_Environment
return $this; return $this;
} }
/** /**
* Loads a template by name. * Loads a template by name.
* *
* @param string $name The template name * @param string $name The template name
* @param integer $index The index if it is an embedded template * @param integer $index The index if it is an embedded template
* *
* @return Twig_TemplateInterface A template instance representing the given template name * @return Twig_TemplateInterface A template instance representing the given template name
*/ */
public function loadTemplate($name, $index = null) public function loadTemplate($name, $index = null)
{ {
if (strpos($name, '@') === false) if (strpos($name, '@') === false)
{ {
foreach ($this->namespaceLookUpOrder as $namespace) foreach ($this->namespaceLookUpOrder as $namespace)
{ {
try try
{ {
if ($namespace === '__main__') if ($namespace === '__main__')
{ {
return parent::loadTemplate($name, $index); return parent::loadTemplate($name, $index);
} }
return parent::loadTemplate('@' . $namespace . '/' . $name, $index); return parent::loadTemplate('@' . $namespace . '/' . $name, $index);
} }
catch (Twig_Error_Loader $e) catch (Twig_Error_Loader $e)
{ {
@ -154,9 +155,9 @@ class phpbb_template_twig_environment extends Twig_Environment
} }
else else
{ {
return parent::loadTemplate($name, $index); return parent::loadTemplate($name, $index);
} }
} }
/** /**
* recursive helper to set variables into $context so that Twig can properly fetch them for display * recursive helper to set variables into $context so that Twig can properly fetch them for display