2014-08-28 2 views
0

내 사용자 정의보기 도우미에서 서비스 위치 지정자에 액세스 할 수 없습니다. 여기에 내 코드입니다 : 당신이 서비스 로케이터 특성을 사용하려면 주석 사항에 따라보기 도우미에서 서비스 위치 지정자에 액세스

<?php 
    namespace Sam\View\Helper; 

    use Zend\View\Helper\AbstractHelper; 
    use Zend\ServiceManager\ServiceLocatorAwareTrait; 
    use Zend\ServiceManager\ServiceLocatorAwareInterface; 

    class Authenticated extends AbstractHelper imeplements ServiceLocatorAwareInterface 
    { 
     protected $authservice; 

     public function __invoke() 
     { 
      if (!$this->getAuthService()->hasIdentity()){ 
       return false; 
      } 
      return true;   
     } 

     public function getAuthService() 
     { 
      if (! $this->authservice) { 
       $this->authservice = $this->getServiceLocator()->get('AuthService'); 
      } 
      return $this->authservice; 
     } 
    } 
+0

도우미의 전체 코드입니까? 클래스에'use ServiceLocatorAwareTrait' 행이 누락 된 것 같습니다. –

+0

그래, 그것을 해결했습니다. 감사. – jkushner

+0

대답을해야합니다. – jkushner

답변

1

, 당신은 클래스의 use ServiceLocatorAwareTrait 라인이 필요합니다. 구현중인 ServiceLocatorAware 인터페이스로 정의 된 메소드가 없기 때문에 현재 가지고있는 것은 오류입니다.

관련 문제