This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Templating/TemplateNameParser.php

49 lines
1.1 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Templating;
/**
* TemplateNameParser is the default implementation of TemplateNameParserInterface.
*
* This implementation takes everything as the template name
* and the extension for the engine.
*
* @author Fabien Potencier <fabien@symfony.com>
2011-07-20 09:27:25 +01:00
*
* @api
*/
class TemplateNameParser implements TemplateNameParserInterface
{
/**
* Parses a template to an array of parameters.
*
* @param string $name A template name
*
2011-02-10 17:20:44 +00:00
* @return TemplateReferenceInterface A template
2011-07-20 09:27:25 +01:00
*
* @api
*/
public function parse($name)
{
2011-02-10 17:20:44 +00:00
if ($name instanceof TemplateReferenceInterface) {
return $name;
}
$engine = null;
if (false !== $pos = strrpos($name, '.')) {
$engine = substr($name, $pos + 1);
}
2011-02-10 17:20:44 +00:00
return new TemplateReference($name, $engine);
}
}