1

有没有办法将 Symfony 文件名符号转换Bundle:Controller:Filename为真实的文件路径/var/www/whatever/src/Bundle/Resources/views/Controller/Filename

4

1 回答 1

3

看看这个问题:Resolve local file path from Twig template name。接受的答案说:

“如果您想从控制器中检索路径,您可以使用以下代码:

$parser = $this->container->get('templating.name_parser');
$locator = $this->container->get('templating.locator');

$path = $locator->locate($parser->parse('AcmeProjectBundle::home.html.twig'));

有关更多信息,请查看以下代码:

Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser::parse
Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator::locate

"

于 2013-03-06T17:30:37.323 回答