forked from matt9mg/concrete5-symfony-form
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplateNameParser.php
37 lines (31 loc) · 958 Bytes
/
TemplateNameParser.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace IAmPedroPiedade\Concrete5\Symfony\Form;
use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser;
use Symfony\Component\Templating\TemplateReferenceInterface;
/**
* Class TemplateNameParser
* @package IAmPedroPiedade\Concrete5\Symfony\Form
*/
class TemplateNameParser extends BaseTemplateNameParser
{
/**
* {@inheritdoc}
*/
public function parse($name): TemplateReferenceInterface
{
if ($name instanceof TemplateReferenceInterface) {
return $name;
}
$location = null;
if (false !== $pos = strrpos($name, ':')) {
$location = substr($name, 0, $pos);
$name = substr($name, $pos + 1);
}
$engine = null;
if (false !== $pos = strrpos($name, '.')) {
$engine = substr($name, $pos + 1);
}
return new TemplateReference($location, $name, $engine);
}
}