ZF2 Get params in factory

一世执手 提交于 2019-12-06 05:35:32

Searching for a few hours, in the end asking it on stack, and now I find the answer in a half hour.

I just had to ad this in my factory

$router = $serviceLocator->get('router');
$request = $serviceLocator->get('request');

// Get the router match
$routerMatch = $router->match($request);
$this->slug = $routerMatch->getParam("slug");

Or the following for ZF3:

$container->get('Application')->getMvcEvent()->getRouteMatch()->getParam('whateverYouWant', false);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!