根据文档:
除了使用逻辑名或完全限定的类名之外,Symfony 还支持第三种引用控制器的方式。此方法仅使用一个冒号分隔符(例如 service_name:indexAction)并将控制器称为服务(请参阅如何将控制器定义为服务)。
将此控制器作为服务(id 为gremo_skebby.controller.report
):
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="gremo_skebby.controller.report.class">
Gremo\SkebbyBundle\Controller\ReportController
</parameter>
<parameter key="gremo_skebby.request.param_converter.report_event.class">
Gremo\SkebbyBundle\Request\ParamConverter\ReportEventParamConverter
</parameter>
</parameters>
<services>
<service id="gremo_skebby.request.param_converter.report_event"
class="%gremo_skebby.request.param_converter.report_event.class%">
<tag name="request.param_coverter" />
</service>
<service id="gremo_skebby.controller.report"
class="%gremo_skebby.controller.report.class%">
<argument id="dispatcher" type="service" />
</service>
</services>
</container>
如何/skebby/notify
在routing.xml
文件中定义路线?
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="gremo_skebby_report_notify" pattern="/skebby/notify">
<default key="_controller">???</default>
<requirement key="_method">GET</requirement>
</route>
</routes>