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;
}
}
도우미의 전체 코드입니까? 클래스에'use ServiceLocatorAwareTrait' 행이 누락 된 것 같습니다. –
그래, 그것을 해결했습니다. 감사. – jkushner
대답을해야합니다. – jkushner