hum*_*pdi 22 controller symfony
我需要控制器内部动作的完整路径,通过电子邮件发送.我怎样才能{{ path('_route') }}从我的控制器内部实现类似的东西?
Alb*_*ona 43
如果你想要本地路径,胡安的答案是正确的.绝对路径 - 有助于通过电子邮件发送 - 需要额外的参数:
$url = $this->generateUrl('your_route_name', array(), true);
Run Code Online (Sandbox Code Playgroud)
第三个参数表示要生成绝对路径.
如果要在视图中使用此URL,只需$url在操作中添加响应数组并使用它.
Sam*_*adi 28
Symfony 3+
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
$this->generateUrl('your_route_name', array('/* your route parameters */'), UrlGeneratorInterface::ABSOLUTE_URL);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22038 次 |
| 最近记录: |