Zend2:如何添加自定义路由类型


Zend2: how to add custom route type?

我有一个类'Foo'BarRoute实现路由接口('Zend'Mvc'Router'RouteInterface)。

如何将'Foo'BarRoute添加为bar路由插件并使其在配置中可用(例如'type' => 'bar')?

到目前为止,我得到了下面的Module.php没有任何效果:(
public function onBootstrap(EventInterface $e)
{
    $routePluginManager = $e->getRouter()->getRoutePluginManager();
    $routePluginManager->setInvokableClass('bar', ''Foo'BarRoute');
}

这只能通过模块配置文件完成吗?

谢谢!

为什么不直接在module.config.php中设置自定义路由类的FQCN ?如果你只需要在你的模块配置文件中使用它。

<>之前返回数组('router' => array('routes' => array('home' => array('type' => 'Foo'BarRoute','options' => array('route' => '/','defaults' => array(),),),),),…);