bug #12894 [FrameworkBundle][Template name] avoid error message for the shortcut n... (aitboudad)
This PR was merged into the 2.3 branch.
Discussion
----------
[FrameworkBundle][Template name] avoid error message for the shortcut n...
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Fixed tickets | #12249, #12254
| Tests pass? | yes
| License | MIT
Commits
-------
055129c
[FrameworkBundle][Template name] avoid error message for the shortcut notation.
This commit is contained in:
commit
a835b18203
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace Symfony\Bundle\FrameworkBundle\Templating;
|
||||
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
use Symfony\Component\Templating\TemplateReferenceInterface;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
|
||||
|
||||
/**
|
||||
* TemplateNameParser converts template names from the short notation
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\HttpKernel\KernelInterface;
|
|||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class TemplateNameParser implements TemplateNameParserInterface
|
||||
class TemplateNameParser extends BaseTemplateNameParser
|
||||
{
|
||||
protected $kernel;
|
||||
protected $cache;
|
||||
|
@ -57,7 +57,7 @@ class TemplateNameParser implements TemplateNameParserInterface
|
|||
}
|
||||
|
||||
if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
|
||||
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
|
||||
return parent::parse($name);
|
||||
}
|
||||
|
||||
$template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]);
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
|
|||
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
|
||||
|
||||
class TemplateNameParserTest extends TestCase
|
||||
{
|
||||
|
@ -63,25 +64,17 @@ class TemplateNameParserTest extends TestCase
|
|||
array(':Post:index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
|
||||
array('::index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
|
||||
array('FooBundle:Post:foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
|
||||
array('/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
|
||||
array('name.twig', new BaseTemplateReference('name.twig', 'twig')),
|
||||
array('name', new BaseTemplateReference('name')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getInvalidLogicalNameProvider
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
public function testParseInvalidName($name)
|
||||
public function testParseValidNameWithNotFoundBundle()
|
||||
{
|
||||
$this->parser->parse($name);
|
||||
}
|
||||
|
||||
public function getInvalidLogicalNameProvider()
|
||||
{
|
||||
return array(
|
||||
array('BarBundle:Post:index.html.php'),
|
||||
array('FooBundle:Post:index'),
|
||||
array('FooBundle:Post'),
|
||||
array('FooBundle:Post:foo:bar'),
|
||||
);
|
||||
$this->parser->parse('BarBundle:Post:index.html.php');
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue