Ejemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $this->aclProvider = $this->prophesize(MutableAclProviderInterface::class);
     $this->objectIdentityRetrievalStrategy = $this->prophesize(ObjectIdentityRetrievalStrategyInterface::class);
     $this->securityIdentityRetrievalStrategy = $this->prophesize(SecurityIdentityRetrievalStrategyInterface::class);
     $this->permissionMap = $this->prophesize(PermissionMapInterface::class);
     $this->token = $this->prophesize(TokenInterface::class);
     $this->accessControlVoter = new AccessControlVoter($this->aclProvider->reveal(), $this->objectIdentityRetrievalStrategy->reveal(), $this->securityIdentityRetrievalStrategy->reveal(), $this->permissionMap->reveal());
 }
 /**
  * Get all Security Identity Ids
  *
  * @param array $shareScope
  *
  * @return array|int
  */
 protected function getSecurityIdentityIds(array $shareScope)
 {
     if ($this->sids !== null) {
         $sidIds = $this->getSecurityIdentityIdsByScope($this->sids, $shareScope);
         return count($sidIds) === 1 ? $sidIds[0] : $sidIds;
     }
     $sids = $this->sidStrategy->getSecurityIdentities($this->getSecurityContext()->getToken());
     $sidByDb = [];
     foreach ($sids as $sid) {
         $entitySid = $this->getSecurityIdentityId($sid);
         if ($entitySid) {
             $sidByDb[$entitySid->getId()] = $sid;
         }
     }
     $this->sids = $sidByDb;
     $sidIds = $this->getSecurityIdentityIdsByScope($this->sids, $shareScope);
     return count($sidIds) === 1 ? $sidIds[0] : $sidIds;
 }
Ejemplo n.º 3
0
 /**
  * Determines if object is shared with current user. If record was shared for user through
  * organization or business unit only, this method will return true.
  *
  * @param object $object
  * @param TokenInterface $token
  *
  * @return bool
  */
 public function isObjectSharedWithUser($object, TokenInterface $token)
 {
     return $this->isObjectSharedWithSids($object, $this->sidRetrievalStrategy->getSecurityIdentities($token));
 }