8000 bug #12894 [FrameworkBundle][Template name] avoid error message for … · symfony/symfony@a835b18 · GitHub
[go: up one dir, main page]

Skip to content

Commit a835b18

Browse files
committed
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.
2 parents f031154 + 055129c commit a835b18

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 8000 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;
@@ -57,7 +57,7 @@ public function parse($name)
5757
}
5858

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

6363
$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)
0