【问题标题】:Convert Bundle:Controller:Filename to actual file path将 Bundle:Controller:Filename 转换为实际文件路径
【发布时间】:2013-03-06 17:27:00
【问题描述】:

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

【问题讨论】:

标签: symfony


【解决方案1】:

看看这个问题: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

"

【讨论】:

  • 我知道我以前在某个地方看到过这个......只有“解决”这个词没有出现在我的脑海中。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-18
  • 1970-01-01
  • 2013-11-27
  • 2012-12-19
  • 2015-02-22
  • 1970-01-01
相关资源
最近更新 更多