Loading src/UnicaenAuth/Assertion/AbstractAssertion.php +29 −56 Original line number Diff line number Diff line Loading @@ -3,11 +3,11 @@ namespace UnicaenAuth\Assertion; use BjyAuthorize\Service\Authorize; use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait; use UnicaenAuth\Service\AuthorizeService; use UnicaenAuth\Service\Traits\AuthorizeServiceAwareTrait; use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait; use UnicaenAuth\Service\UserContext; use Zend\Mvc\MvcEvent; use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger; use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Assertion\AssertionInterface; use Zend\Permissions\Acl\Resource\ResourceInterface; Loading @@ -18,10 +18,10 @@ use Zend\Permissions\Acl\Role\RoleInterface; * * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface abstract class AbstractAssertion implements AssertionInterface { use ServiceLocatorAwareTrait; use UserContextServiceAwareTrait; use AuthorizeServiceAwareTrait; /** * @var Acl Loading @@ -34,9 +34,22 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw private $role = false; /** * @var FlashMessenger * @var MvcEvent */ private $fm; private $mvcEvent; public function __construct( MvcEvent $mvcEvent, AuthorizeService $serviceAuthorize, UserContext $serviceUserContext ) { $this->setMvcEvent($mvcEvent); $this->setServiceAuthorize($serviceAuthorize); $this->setServiceUserContext($serviceUserContext); } Loading Loading @@ -120,6 +133,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw if (!$this->acl) { $this->acl = $this->getServiceAuthorize()->getAcl(); } return $this->acl; } Loading Loading @@ -150,6 +164,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw $this->role = $sUserContext->getSelectedIdentityRole(); } } return $this->role; } Loading Loading @@ -295,19 +310,15 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw return true; } /** * @var MvcEvent */ private $mvcEvent; /** * @param MvcEvent $mvcEvent */ public function setMvcEvent(MvcEvent $mvcEvent) { $this->mvcEvent = $mvcEvent; } /** * @return MvcEvent */ Loading @@ -316,42 +327,4 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw return $this->mvcEvent; } /** * @var Authorize */ private $serviceAuthorize; /** * @param Authorize $serviceAuthorize */ public function setServiceAuthorize(Authorize $serviceAuthorize) { $this->serviceAuthorize = $serviceAuthorize; } /** * @return Authorize */ private function getServiceAuthorize() { return $this->serviceAuthorize; } /** * @param FlashMessenger $fm * @deprecated Merci d'abandonner cette méthode : SoC violation ! */ public function setFlashMessenger(FlashMessenger $fm) { $this->fm = $fm; } /** * @return FlashMessenger * @deprecated Merci d'abandonner cette méthode : SoC violation ! */ protected function flashMessenger() { return $this->fm; } } No newline at end of file src/UnicaenAuth/Assertion/AssertionFactory.php 0 → 100644 +40 −0 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Assertion; use BjyAuthorize\Service\Authorize; use Interop\Container\ContainerInterface; use Zend\Authentication\AuthenticationService; use Zend\Mvc\Application; use Zend\ServiceManager\Factory\FactoryInterface; /** * Class AssertionFactory * * @package UnicaenAuth\Assertion */ class AssertionFactory implements FactoryInterface { /** * @param ContainerInterface $container * * @return UserContext */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /* @var $application Application */ $application = $container->get('Application'); $mvcEvent = $application->getMvcEvent(); /* @var $serviceAuthorize Authorize */ $serviceAuthorize = $container->get('BjyAuthorize\Service\Authorize'); /** @var UserContext $serviceUserContext */ $serviceUserContext = $container->get('UnicaenAuth\Service\UserContext'); /* @var $assertion AbstractAssertion */ $assertion = new $requestedName($mvcEvent, $serviceAuthorize, $serviceUserContext); return $assertion; } } No newline at end of file Loading
src/UnicaenAuth/Assertion/AbstractAssertion.php +29 −56 Original line number Diff line number Diff line Loading @@ -3,11 +3,11 @@ namespace UnicaenAuth\Assertion; use BjyAuthorize\Service\Authorize; use UnicaenApp\ServiceManager\ServiceLocatorAwareInterface; use UnicaenApp\ServiceManager\ServiceLocatorAwareTrait; use UnicaenAuth\Service\AuthorizeService; use UnicaenAuth\Service\Traits\AuthorizeServiceAwareTrait; use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait; use UnicaenAuth\Service\UserContext; use Zend\Mvc\MvcEvent; use Zend\Mvc\Plugin\FlashMessenger\FlashMessenger; use Zend\Permissions\Acl\Acl; use Zend\Permissions\Acl\Assertion\AssertionInterface; use Zend\Permissions\Acl\Resource\ResourceInterface; Loading @@ -18,10 +18,10 @@ use Zend\Permissions\Acl\Role\RoleInterface; * * @author Laurent LÉCLUSE <laurent.lecluse at unicaen.fr> */ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface abstract class AbstractAssertion implements AssertionInterface { use ServiceLocatorAwareTrait; use UserContextServiceAwareTrait; use AuthorizeServiceAwareTrait; /** * @var Acl Loading @@ -34,9 +34,22 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw private $role = false; /** * @var FlashMessenger * @var MvcEvent */ private $fm; private $mvcEvent; public function __construct( MvcEvent $mvcEvent, AuthorizeService $serviceAuthorize, UserContext $serviceUserContext ) { $this->setMvcEvent($mvcEvent); $this->setServiceAuthorize($serviceAuthorize); $this->setServiceUserContext($serviceUserContext); } Loading Loading @@ -120,6 +133,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw if (!$this->acl) { $this->acl = $this->getServiceAuthorize()->getAcl(); } return $this->acl; } Loading Loading @@ -150,6 +164,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw $this->role = $sUserContext->getSelectedIdentityRole(); } } return $this->role; } Loading Loading @@ -295,19 +310,15 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw return true; } /** * @var MvcEvent */ private $mvcEvent; /** * @param MvcEvent $mvcEvent */ public function setMvcEvent(MvcEvent $mvcEvent) { $this->mvcEvent = $mvcEvent; } /** * @return MvcEvent */ Loading @@ -316,42 +327,4 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw return $this->mvcEvent; } /** * @var Authorize */ private $serviceAuthorize; /** * @param Authorize $serviceAuthorize */ public function setServiceAuthorize(Authorize $serviceAuthorize) { $this->serviceAuthorize = $serviceAuthorize; } /** * @return Authorize */ private function getServiceAuthorize() { return $this->serviceAuthorize; } /** * @param FlashMessenger $fm * @deprecated Merci d'abandonner cette méthode : SoC violation ! */ public function setFlashMessenger(FlashMessenger $fm) { $this->fm = $fm; } /** * @return FlashMessenger * @deprecated Merci d'abandonner cette méthode : SoC violation ! */ protected function flashMessenger() { return $this->fm; } } No newline at end of file
src/UnicaenAuth/Assertion/AssertionFactory.php 0 → 100644 +40 −0 Original line number Diff line number Diff line <?php namespace UnicaenAuth\Assertion; use BjyAuthorize\Service\Authorize; use Interop\Container\ContainerInterface; use Zend\Authentication\AuthenticationService; use Zend\Mvc\Application; use Zend\ServiceManager\Factory\FactoryInterface; /** * Class AssertionFactory * * @package UnicaenAuth\Assertion */ class AssertionFactory implements FactoryInterface { /** * @param ContainerInterface $container * * @return UserContext */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { /* @var $application Application */ $application = $container->get('Application'); $mvcEvent = $application->getMvcEvent(); /* @var $serviceAuthorize Authorize */ $serviceAuthorize = $container->get('BjyAuthorize\Service\Authorize'); /** @var UserContext $serviceUserContext */ $serviceUserContext = $container->get('UnicaenAuth\Service\UserContext'); /* @var $assertion AbstractAssertion */ $assertion = new $requestedName($mvcEvent, $serviceAuthorize, $serviceUserContext); return $assertion; } } No newline at end of file