Check if User has a Role(s) associated.

@param string|array $name The role to check.

@return bool
771690
public function hasRole($name)
    {
        if (!$this->relationLoaded('role')) {
            $this->load('role');
        }

        return in_array($this->role->name, (is_array($name) ? $name : [$name]));
    }
167097
public function has(string $name): bool
    {
        foreach ($this->elements as $element) {
            if ($element instanceof NamedInterface && $element->getName() == $name) {
                return true;
            }
        }

        return false;
    }
70664
public function is($roleName)
    {
        if (is_array($roleName)) {
            return $this->hasRoles($roleName);
        }

        return $this->hasRole($roleName);
    }
1033695
public boolean hasRoleForUser(String name, String role) {
        List<String> roles = getRolesForUser(name);

        boolean hasRole = false;
        for (String r : roles) {
            if (r.equals(role)) {
                hasRole = true;
                break;
            }
        }

        return hasRole;
    }
730702
public function hasDirectRole($name)
    {
        foreach ($this->roles as $role) {
            if ($role->name == $name) {
                return true;
            }
        }

        return false;
    }
107562
public function hasRole($role_name)
    {

        if ($this->hasSuperUser())
            return true;

        foreach ($this->group->roles as $role)
            if ($role->title == $role_name)
                return true;

        return false;

    }
582569
public function hasOneRole($role)
    {
        foreach ($this->getArrayFrom($role) as $role) {
            if ($this->checkRole($role)) {
                return true;
            }
        }

        return false;
    }
863339
public function has($name):bool
    {
        return ((isset($this->session[$name]) && null != $this->session[$name])? true : false);
    }
90127
public function has($name)
    {
        $value = $this->get($name);

        return isset($value) ? $value : false;
    }
715016
public function hasGroupForName($name)
    {
        if ($this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $name)) {
            return true;
        }
        
        return false;
    }
330039
protected function _checkRole() {
        if (in_array($this->_role, array_map('trim', explode(',', $this->request->access))) || $this->request->access == '*') {
            return true;
        }
        else {
            return false;
        }
    }
752880
public function hasColumn($name)
    {
        $name = $this->filterInputColumn($name);

        return in_array($name, $this->getFields());
    }
286826
public function hasRoleForUser($name, $role)
    {
        $roles = $this->getRolesForUser($name);

        $hasRole = false;
        foreach ($roles as $r) {
            if ($r == $role) {
                $hasRole = true;

                break;
            }
        }

        return $hasRole;
    }
1272103
public function hasRole($name, $requireAll = false)
    {
        if (is_array($name)) {
            foreach ($name as $roleName) {
                $hasRole = $this->hasRole($roleName);

                if ($hasRole && !$requireAll) {
                    return true;
                } elseif (!$hasRole && $requireAll) {
                    return false;
                }
            }

            // If we've made it this far and $requireAll is FALSE, then NONE of the roles were found
            // If we've made it this far and $requireAll is TRUE, then ALL of the roles were found.
            // Return the value of $requireAll;
            return $requireAll;
        } else {
            foreach ($this->cachedRoles() as $role) {
                if ($role->name == $name) {
                    return true;
                }
            }
        }

        return false;
    }
529590
public function hasRole($role) {
        $roles = (array) $this->Session->read('Acl.roles');

        if (is_numeric($role)) {
            return isset($roles[$role]);
        }

        return in_array($role, $roles);
    }
198188
public function hasField(string $name) : bool
    {
        return isset($this->fields[$name]) && $this->fields[$name];
    }
1072544
public function is($name)
    {
        foreach ($this->roles as $role) {
            if ($role->name == $name || $role->slug == $name || $role->id == $name) {
                return true;
            }
        }

        return false;
    }