Exemplo n.º 1
0
 /**
  * Check if this feature is active for the given userId
  * @param RolloutAbstract $rollout
  * @param DeterminableUserInterface|null $user
  * @internal param int $userId
  * @return bool
  */
 public function isActive(RolloutAbstract $rollout, DeterminableUserInterface $user = null)
 {
     if (100 === $this->getPercentage()) {
         return true;
     }
     if (!$user instanceof DeterminableUserInterface) {
         return false;
     }
     $userId = $user->getId();
     if (true === $this->isUserInPercentage($userId) || true === $this->isUserInActiveUsers($userId) || true === $this->isUserInActiveRole($user, $rollout) || true === $this->isUserInActiveGroup($user, $rollout)) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Checks if a user has the given group
  * @param string $groupName
  * @param DeterminableUserInterface $user
  * @return bool
  */
 public function userHasGroup($groupName, DeterminableUserInterface $user)
 {
     $userHasGroup = false;
     if (true === in_array($groupName, $user->getGroups())) {
         $userHasGroup = true;
     }
     return $userHasGroup;
 }