2013-04-30 1 views
0

나는 ..

class User implements ServiceLocatorAwareInterface 
{ 

} 

여기 $this->url() for views 비슷한을 사용하려면로 정의 zf2 모듈의 서비스 로케이터를

이것이 가능한가.. ?

답변

3

모델에 ServiceLocatorAwareInterface이 구현되어 있기 때문에 유용합니다.

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

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

자세한 내용은 Zend\View\Helper\Url#__invoke()을 참조하십시오.

+0

고마워 선생님 .. 그게 효과가 있습니다. 이처럼 어떤 도우미라도 부를 수 있습니까? – alwaysLearn

+0

내가 이렇게 말하게하면 : 어디서 작동하지 않는지도 모르겠다.) – Sam

+0

baseUrl()을 시도하고 있지만 작동하지 않는다. – alwaysLearn