[FrameworkBundle] Improved TemplateNameParser performance
This commit is contained in:
parent
b13af94e01
commit
f092c7f704
@ -56,19 +56,11 @@ class TemplateNameParser implements TemplateNameParserInterface
|
||||
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));
|
||||
}
|
||||
|
||||
$parts = explode(':', $name);
|
||||
if (3 !== count($parts)) {
|
||||
if (!preg_match('/^([^:]*):([^:]*):(.+)\.([^\.]+)\.([^\.]+)$/', $name, $matches)) {
|
||||
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
|
||||
}
|
||||
|
||||
$elements = explode('.', $parts[2]);
|
||||
if (3 > count($elements)) {
|
||||
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid (format is "bundle:section:template.format.engine").', $name));
|
||||
}
|
||||
$engine = array_pop($elements);
|
||||
$format = array_pop($elements);
|
||||
|
||||
$template = new TemplateReference($parts[0], $parts[1], implode('.', $elements), $format, $engine);
|
||||
$template = new TemplateReference($matches[1], $matches[2], $matches[3], $matches[4], $matches[5]);
|
||||
|
||||
if ($template->get('bundle')) {
|
||||
try {
|
||||
|
Reference in New Issue
Block a user