且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ZF2,将变量从控制器传递给自定义元素

更新时间:2023-09-10 20:58:46

您可以通过工厂内的路由匹配"实例获取 ID.

You can fetch the id via the 'route match' instance inside the factory.

$event = $serviceManager->get('Application')->getMvcEvent();
$id = $event->getRouteMatch()->getParam('id', false);

if (empty($id)) {
   throw new ServiceNotCreatedException('id not set!');
}

$descriptions = $mapper->findDescriptions($id);