Loading src/UnicaenAuth/Service/Traits/AuthorizeServiceAwareTrait.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Service\Traits; use UnicaenAuth\Service\AuthorizeService; use RuntimeException; /** * Description of AuthorizeServiceAwareTrait * * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ trait AuthorizeServiceAwareTrait { /** * @var AuthorizeService */ private $serviceAuthorize; /** * @param AuthorizeService $serviceAuthorize * * @return self */ public function setServiceAuthorize(AuthorizeService $serviceAuthorize) { $this->serviceAuthorize = $serviceAuthorize; return $this; } /** * @return AuthorizeService * @throws RuntimeException */ public function getServiceAuthorize() { if (empty($this->serviceAuthorize)) { if (!method_exists($this, 'getServiceLocator')) { throw new RuntimeException('La classe ' . get_class($this) . ' n\'a pas accès au ServiceLocator.'); } $serviceLocator = $this->getServiceLocator(); if (method_exists($serviceLocator, 'getServiceLocator')) { $serviceLocator = $serviceLocator->getServiceLocator(); } $this->serviceAuthorize = $serviceLocator->get('BjyAuthorize\Service\Authorize'); } return $this->serviceAuthorize; } } No newline at end of file Loading
src/UnicaenAuth/Service/Traits/AuthorizeServiceAwareTrait.php 0 → 100644 +56 −0 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Service\Traits; use UnicaenAuth\Service\AuthorizeService; use RuntimeException; /** * Description of AuthorizeServiceAwareTrait * * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ trait AuthorizeServiceAwareTrait { /** * @var AuthorizeService */ private $serviceAuthorize; /** * @param AuthorizeService $serviceAuthorize * * @return self */ public function setServiceAuthorize(AuthorizeService $serviceAuthorize) { $this->serviceAuthorize = $serviceAuthorize; return $this; } /** * @return AuthorizeService * @throws RuntimeException */ public function getServiceAuthorize() { if (empty($this->serviceAuthorize)) { if (!method_exists($this, 'getServiceLocator')) { throw new RuntimeException('La classe ' . get_class($this) . ' n\'a pas accès au ServiceLocator.'); } $serviceLocator = $this->getServiceLocator(); if (method_exists($serviceLocator, 'getServiceLocator')) { $serviceLocator = $serviceLocator->getServiceLocator(); } $this->serviceAuthorize = $serviceLocator->get('BjyAuthorize\Service\Authorize'); } return $this->serviceAuthorize; } } No newline at end of file