$ this-> url()类似于zend框架中的服务定位器中的东西

时间:2013-04-30 12:02:30

标签: php zend-framework zend-framework2

我在zf2模块中有一个定义为

的服务定位器
class User implements  ServiceLocatorAwareInterface
{

}

我想在这里使用与$this->url() for views类似的东西..

这可能......?

1 个答案:

答案 0 :(得分:4)

由于您的模型实现了ServiceLocatorAwareInterface,因此它是。

$sl  = $this->getServiceLocator();
$vhm = $sl->get('viewhelpermanager');
$url = $vhm->get('url');

$urlString = $url($name, $params, $options, $reuseMatchedParams);

有关参数的详细信息,请参阅Zend\View\Helper\Url#__invoke()