Skip to content
Snippets Groups Projects
Commit a80a7a0a authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Stop using the deprecated TemplateLoader::parseName() method.

It was deprecated in Twig 1.x and removed in 2.0.
parent 22c51125
No related branches found
No related tags found
No related merge requests found
...@@ -16,9 +16,9 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader ...@@ -16,9 +16,9 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader
* *
* @inheritdoc * @inheritdoc
*/ */
protected function findTemplate($name) protected function findTemplate($name, $throw = true)
{ {
list($namespace, $shortname) = $this->parseName($name); list($namespace, $shortname) = $this->parseModuleName($name);
if (!in_array($namespace, $this->paths, true) && $namespace !== self::MAIN_NAMESPACE) { if (!in_array($namespace, $this->paths, true) && $namespace !== self::MAIN_NAMESPACE) {
$this->addPath(self::getModuleTemplateDir($namespace), $namespace); $this->addPath(self::getModuleTemplateDir($namespace), $namespace);
} }
...@@ -26,7 +26,15 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader ...@@ -26,7 +26,15 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader
} }
protected function parseName($name, $default = self::MAIN_NAMESPACE) /**
* Parse the name of a template in a module.
*
* @param string $name The full name of the template, including namespace and template name / path.
*
* @return array An array with the corresponding namespace and name of the template. The namespace defaults to
* \Twig\Loader\FilesystemLoader::MAIN_NAMESPACE, if none was specified in $name.
*/
protected function parseModuleName($name, $default = self::MAIN_NAMESPACE)
{ {
if (strpos($name, ':')) { if (strpos($name, ':')) {
// we have our old SSP format // we have our old SSP format
...@@ -37,7 +45,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader ...@@ -37,7 +45,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader
)); ));
return array($namespace, $shortname); return array($namespace, $shortname);
} }
return parent::parseName($name, $default); return [$default, $name];
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment