Check if an entity is compatible with another.

@param HasRolesInterface $hasRoles

@return bool
517825
public function isCompatibleWith(HasRolesInterface $hasRoles)
    {
        $roles = $hasRoles->getRoles();
        $filled = array_intersect($this->roles, $roles);

        return is_null($roles) || count($filled) === count($roles);
    }
1309949
public function is($roles)
	{
		if (!$this->user())
		{
			return false;
		}

		$userRoles = $this->getUser()->roles;

		foreach ((array)$roles as $role)
		{
			if (in_array(mb_strtolower($role), $userRoles)
				|| in_array($role, $userRoles)
			)
			{
				return true;
			}
		}

		return false;
	}
220250
final public function hasRequiredRole(UserInterface $user = null, array $roles = [])
    {
        if ($user != null) {
            // Check if user's roles matches required roles
            $userRoles = $user->getRoles();

            foreach ($userRoles as $role) {
                if (\in_array($role, $roles)) {
                    return true;
                }
            }
        }

        return false;
    }
377223
public static function hasRole($roles)
    {
        $user = wp_get_current_user();

        if (is_string($roles)) {
            $roles = array($roles);
        }

        if (!array_intersect($roles, $user->roles)) {
            return false;
        }

        return true;
    }
853353
public static function satisfies($version, $constraints)
    {
        if (null === self::$versionParser) {
            self::$versionParser = new VersionParser();
        }

        $versionParser = self::$versionParser;
        $provider = new Constraint('==', $versionParser->normalize($version));
        $constraints = $versionParser->parseConstraints($constraints);

        return $constraints->matches($provider);
    }
642464
public function hasRole($role)
    {
        if (!$this->roles->where('token', $role)->isEmpty()) {
            return true;
        }

        foreach ($this->groups as $group) {
            if (!$group->roles->where('token', $role)->isEmpty()) {
                return true;
            }
        }

        return false;
    }
958132
public function findByRoles(array $roles, $getQuery = false)
    {
        $dql = "
            SELECT u FROM Claroline\CoreBundle\Entity\User u
            JOIN u.roles r WHERE r IN (:roles) AND u.isEnabled = true
            ORDER BY u.lastName
            ";

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roles', $roles);

        return ($getQuery) ? $query: $query->getResult();
    }
23328
public function hasOne($entity, callable $callback = null, $alias = null)
    {
        $relation = $this->returnRelation(HasOne::class, $entity, $callback, $alias);

        return $relation;
    }
256663
public function has($name, $checkAbstractFactories = true, $usePeeringServiceManagers = false)
    {
        if (is_string($name) && $this->container->has($name)) {
            return true;
        } elseif (parent::has($name, $checkAbstractFactories, $usePeeringServiceManagers)) {
            return true;
        }

        return false;
    }
313830
public function supportsEntity(EntityInterface $entity): bool
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                return true;
            }
        }

        return false;
    }
1023968
public function hasRole($requestedRole) {
		$roles = $this->user($this->getConfig('roleField'));
		if (is_null($roles)) {
			return false;
		}

		return $this->_checkRoles($requestedRole, $roles);
	}
694535
public function hasAlias($hasAlias=null)
    {
        if (is_null($hasAlias)) {
            return (bool) $this->hasAlias[0];
        }
        
        $this->hasAlias = $hasAlias;
        return $this;
    }
69197
public function hasResource(ResourceInterface $otherResource) {
		if ($this->isEmpty()) {
			return false;
		}
		if ($this->type === RelationshipObject::TO_ONE) {
			return $this->resource->getResource()->equals($otherResource->getResource());
		}
		if ($this->type === RelationshipObject::TO_MANY) {
			foreach ($this->resources as $ownResource) {
				if ($ownResource->getResource()->equals($otherResource->getResource())) {
					return true;
				}
			}
		}
		
		return false;
	}
523702
protected boolean hasRolesInOtherOus() {

        if (m_hasRolesInOtherOus == null) {
            m_hasRolesInOtherOus = Boolean.FALSE;
            try {
                Iterator<CmsRole> itRoles = getRoles().iterator();
                while (itRoles.hasNext()) {
                    CmsRole role = itRoles.next();
                    if (!role.getOuFqn().equals(getParamOufqn())) {
                        m_hasRolesInOtherOus = Boolean.TRUE;
                        break;
                    }
                }
            } catch (Exception e) {
                // ignore
            }
        }
        return m_hasRolesInOtherOus.booleanValue();
    }
1318280
public function matchIdentityRoles(array $roles): bool
    {
        $identityRoles = $this->getIdentityRoles();
        // Too easy...
        if (empty($identityRoles)) {
            return false;
        }
        $roleNames = [];
        foreach ($roles as $role) {
            $roleNames[] = $role instanceof RoleInterface ? $role->getName() : (string)$role;
        }

        $identityRoleNames = [];
        foreach ($this->flattenRoles($identityRoles) as $role) {
            $identityRoleNames[] = $role->getName();
        }

        return count(array_intersect($roleNames, $identityRoleNames)) > 0;
    }
1361378
public function isScenarioMatch(FeatureNode $feature, ScenarioInterface $scenario)
    {
        return $this->isTagsMatchCondition(array_merge($feature->getTags(), $scenario->getTags()));
    }
315715
public function attachRole($role)
    {
        return (!$this->getRoles()->contains($role)) ? $this->roles()->attach($role) : true;
    }