我有一个类'Foo'BarRoute
实现路由接口('Zend'Mvc'Router'RouteInterface
)。
如何将'Foo'BarRoute
添加为bar
路由插件并使其在配置中可用(例如'type' => 'bar'
)?
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(),),),),),…);