Commit c3bcb1e9 authored by Laurent Lécluse's avatar Laurent Lécluse
Browse files

Correction de bug

parent ab04aec4
......@@ -2,6 +2,8 @@
namespace UnicaenAuth\Assertion;
use BjyAuthorize\Service\Authorize;
use UnicaenAuth\Service\Traits\UserContextServiceAwareTrait;
use Zend\Mvc\Application;
use Zend\Mvc\MvcEvent;
use Zend\Permissions\Acl\Acl;
......@@ -19,6 +21,7 @@ use Zend\ServiceManager\ServiceLocatorAwareTrait;
abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAwareInterface
{
use ServiceLocatorAwareTrait;
use UserContextServiceAwareTrait;
/**
* @var Acl
......@@ -28,7 +31,7 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
/**
* @var RoleInterface
*/
private $role;
private $role = false;
......@@ -94,6 +97,9 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/
public function getAcl()
{
if (!$this->acl){
$this->acl = $this->getServiceAuthorize()->getAcl();
}
return $this->acl;
}
......@@ -118,6 +124,12 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
*/
public function getRole()
{
if (false === $this->role){
$sUserContext = $this->getServiceUserContext();
if ($sUserContext->getIdentity()) {
$this->role = $sUserContext->getSelectedIdentityRole();
}
}
return $this->role;
}
......@@ -244,4 +256,17 @@ abstract class AbstractAssertion implements AssertionInterface, ServiceLocatorAw
return $application->getMvcEvent();
}
/**
* @return Authorize
*/
private function getServiceAuthorize()
{
$serviceAuthorize = $this->getServiceLocator()->get('BjyAuthorize\Service\Authorize');
/* @var $serviceAuthorize Authorize */
return $serviceAuthorize;
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
namespace UnicaenAuth\Service\Traits;
use UnicaenAuth\Service\UserContextService;
use UnicaenAuth\Service\UserContext;
use RuntimeException;
/**
......@@ -13,18 +13,18 @@ use RuntimeException;
trait UserContextServiceAwareTrait
{
/**
* @var UserContextService
* @var UserContext
*/
private $serviceUserContext;
/**
* @param UserContextService $serviceUserContext
* @param UserContext $serviceUserContext
*
* @return self
*/
public function setServiceUserContext(UserContextService $serviceUserContext)
public function setServiceUserContext(UserContext $serviceUserContext)
{
$this->serviceUserContext = $serviceUserContext;
......@@ -34,7 +34,7 @@ trait UserContextServiceAwareTrait
/**
* @return UserContextService
* @return UserContext
* @throws RuntimeException
*/
public function getServiceUserContext()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment