在模板中,我通过子请求包含组件:
{% extends 'HnDocumentBundle:Default:PrintableDocumentLayout.html.twig' %}
{% block printable_document_content %}
{{ render(controller('HnDocumentBundle:Component/TraineeEducationVoucher:educationVoucherBackToAgencyAgent', { trainee: trainee.id })) }}
{% endblock %}
片段没有定义路由名称,我不希望它们有一个。但是我仍然希望能够在开发模式下直接访问片段。
我的工作是假设通过使我的本地计算机访问该站点成为可信代理而使片段可用。因此,我配置了框架:
framework:
trusted_proxies:
- 192.168.56.1
fragments:
enabled: true
path: /_fragment/
在调试工具栏上,我获得了片段的链接,它看起来像预期的那样:
http://localhost.dev/app_dev.php/_fragment/?_path=_format%3Dhtml%26_locale%3Dde%26_controller%3DHnDocumentBundle%253AComponent%252FTraineeEducationVoucher%253AeducationVoucherBackToTrainee
然而,一旦我尝试直接在浏览器中访问,我就会获得访问被拒绝的异常。我希望这会在生产中发生,而不是在发展中。
我做错了什么?如何在开发时使片段URL可用?