Skip to content

Commit 0305ce7

Browse files
committed
[FrameworkBundle][Template name] fixed "the template format is invalid."
1 parent 0e6465a commit 0305ce7

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Templating;
1313

14-
use Symfony\Component\Templating\TemplateNameParserInterface;
1514
use Symfony\Component\Templating\TemplateReferenceInterface;
1615
use Symfony\Component\HttpKernel\KernelInterface;
16+
use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
1717

1818
/**
1919
* TemplateNameParser converts template names from the short notation
@@ -22,7 +22,7 @@
2222
*
2323
* @author Fabien Potencier <fabien@symfony.com>
2424
*/
25-
class TemplateNameParser implements TemplateNameParserInterface
25+
class TemplateNameParser extends BaseTemplateNameParser
2626
{
2727
protected $kernel;
2828
protected $cache = array();
@@ -56,7 +56,7 @@ public function parse($name)
5656
}
5757

5858
if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
59-
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
59+
return parent::parse($name);
6060
}
6161

6262
$template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]);

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
1616
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
17+
use Symfony\Component\Templating\TemplateReference as BaseTemplateReference;
1718

1819
class TemplateNameParserTest extends TestCase
1920
{
@@ -63,25 +64,17 @@ public function getLogicalNameToTemplateProvider()
6364
array(':Post:index.html.php', new TemplateReference('', 'Post', 'index', 'html', 'php')),
6465
array('::index.html.php', new TemplateReference('', '', 'index', 'html', 'php')),
6566
array('FooBundle:Post:foo.bar.index.html.php', new TemplateReference('FooBundle', 'Post', 'foo.bar.index', 'html', 'php')),
67+
array('/path/to/section/name.php', new BaseTemplateReference('/path/to/section/name.php', 'php')),
68+
array('name.twig', new BaseTemplateReference('name.twig', 'twig')),
69+
array('name', new BaseTemplateReference('name')),
6670
);
6771
}
6872

6973
/**
70-
* @dataProvider getInvalidLogicalNameProvider
7174
* @expectedException \InvalidArgumentException
7275
*/
73-
public function testParseInvalidName($name)
76+
public function testParseValidNameWithNotFoundBundle()
7477
{
75-
$this->parser->parse($name);
76-
}
77-
78-
public function getInvalidLogicalNameProvider()
79-
{
80-
return array(
81-
array('BarBundle:Post:index.html.php'),
82-
array('FooBundle:Post:index'),
83-
array('FooBundle:Post'),
84-
array('FooBundle:Post:foo:bar'),
85-
);
78+
$this->parser->parse('BarBundle:Post:index.html.php');
8679
}
8780
}

0 commit comments

Comments
 (0)