mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Use the decorated parser if bundle does not exist
This commit is contained in:
parent
9f1cb34ef3
commit
e934fd095a
2 changed files with 10 additions and 5 deletions
|
|
@ -76,7 +76,7 @@ final class TemplateNameParser implements TemplateNameParserInterface
|
|||
try {
|
||||
$this->kernel->getBundle($template->get('bundle'));
|
||||
} catch (\Exception $e) {
|
||||
throw new \InvalidArgumentException(sprintf('Template name "%s" is not valid.', $name), 0, $e);
|
||||
return $this->decoratedParser->parse($name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,11 +63,16 @@ final class TemplateNameParserSpec extends ObjectBehavior
|
|||
$this->parse('@Acme/Nested/Directory/app.html.twig')->shouldBeLike(new TemplateReference('AcmeBundle', 'Nested/Directory', 'app', 'html', 'twig'));
|
||||
}
|
||||
|
||||
function it_throws_an_exception_if_namespaced_path_references_not_existing_bundle(KernelInterface $kernel)
|
||||
{
|
||||
$kernel->getBundle('AcmeBundle')->willThrow(\Exception::class);
|
||||
function it_delegates_custom_namespace_to_decorated_parser(
|
||||
KernelInterface $kernel,
|
||||
TemplateNameParserInterface $decoratedParser,
|
||||
TemplateReferenceInterface $templateReference
|
||||
) {
|
||||
$kernel->getBundle('myBundle')->willThrow(\Exception::class);
|
||||
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->during('parse', ['@Acme/app.html.twig']);
|
||||
$decoratedParser->parse('@my/custom/namespace.html.twig')->willReturn($templateReference);
|
||||
|
||||
$this->parse('@my/custom/namespace.html.twig')->shouldReturn($templateReference);
|
||||
}
|
||||
|
||||
function it_generates_template_references_from_root_namespaced_paths()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue