src/Auth/AclTrait.php
protected function _getUserRoles($user) {
		// Single-role from session
		if (!$this->getConfig('multiRole')) {
			if (!array_key_exists($this->getConfig('roleColumn'), $user)) {
				throw new Exception(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $this->getConfig('roleColumn')));
			}
			if (!isset($user[$this->getConfig('roleColumn')])) {
				return [];
			}
			return $this->_mapped([$user[$this->getConfig('roleColumn')]]);
		}

		// Multi-role from session
		if (isset($user[$this->getConfig('rolesTable')])) {
			$userRoles = $user[$this->getConfig('rolesTable')];
			if (isset($userRoles[0]['id'])) {
				$userRoles = Hash::extract($userRoles, '{n}.id');
			}
			return $this->_mapped((array)$userRoles);
		}

		// Multi-role from session via pivot table
		$pivotTableName = $this->getConfig('pivotTable');
		if (!$pivotTableName) {
			list(, $rolesTableName) = pluginSplit($this->getConfig('rolesTable'));
			list(, $usersTableName) = pluginSplit($this->getConfig('usersTable'));
			$tables = [
				$usersTableName,
				$rolesTableName
			];
			asort($tables);
			$pivotTableName = implode('', $tables);
		}
		if (isset($user[$pivotTableName])) {
			$userRoles = $user[$pivotTableName];
			if (isset($userRoles[0][$this->getConfig('roleColumn')])) {
				$userRoles = Hash::extract($userRoles, '{n}.' . $this->getConfig('roleColumn'));
			}
			return $this->_mapped((array)$userRoles);
		}

		// Multi-role from DB: load the pivot table
		$roles = $this->_getRolesFromDb($pivotTableName, $user[$this->getConfig('idColumn')]);
		if (!$roles) {
			return [];
		}

		return $this->_mapped($roles);
	}
protected function _getUserRoles($user) {
		// Single-role from session
		if (!$this->getConfig('multiRole')) {
			if (!array_key_exists($this->getConfig('roleColumn'), $user)) {
				throw new Exception(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $this->getConfig('roleColumn')));
			}
			if (!isset($user[$this->getConfig('roleColumn')])) {
				return [];
			}
			return $this->_mapped([$user[$this->getConfig('roleColumn')]]);
		}

		// Multi-role from session
		if (isset($user[$this->getConfig('rolesTable')])) {
			$userRoles = $user[$this->getConfig('rolesTable')];
			if (isset($userRoles[0]['id'])) {
				$userRoles = Hash::extract($userRoles, '{n}.id');
			}
			return $this->_mapped((array)$userRoles);
		}

		// Multi-role from session via pivot table
		$pivotTableName = $this->getConfig('pivotTable');
		if (!$pivotTableName) {
			list(, $rolesTableName) = pluginSplit($this->getConfig('rolesTable'));
			list(, $usersTableName) = pluginSplit($this->getConfig('usersTable'));
			$tables = [
				$usersTableName,
				$rolesTableName
			];
			asort($tables);
			$pivotTableName = implode('', $tables);
		}
		if (isset($user[$pivotTableName])) {
			$userRoles = $user[$pivotTableName];
			if (isset($userRoles[0][$this->getConfig('roleColumn')])) {
				$userRoles = Hash::extract($userRoles, '{n}.' . $this->getConfig('roleColumn'));
			}
			return $this->_mapped((array)$userRoles);
		}

		// Multi-role from DB: load the pivot table
		$roles = $this->_getRolesFromDb($pivotTableName, $user[$this->getConfig('idColumn')]);
		if (!$roles) {
			return [];
		}

		return $this->_mapped($roles);
	}
protected function _getUserRoles ( $ user ) { // Single-role from session if ( ! $ this -> getConfig ( 'multiRole' ) ) { if ( ! array_key_exists ( $ this -> getConfig ( 'roleColumn' ) , $ user ) ) { throw new Exception ( sprintf ( 'Missing TinyAuth role id field (%s) in user session' , 'Auth.User.' . $ this -> getConfig ( 'roleColumn' ) ) ) ; } if ( ! isset ( $ user [ $ this -> getConfig ( 'roleColumn' ) ] ) ) { return [ ] ; } return $ this -> _mapped ( [ $ user [ $ this -> getConfig ( 'roleColumn' ) ] ] ) ; } // Multi-role from session if ( isset ( $ user [ $ this -> getConfig ( 'rolesTable' ) ] ) ) { $ userRoles = $ user [ $ this -> getConfig ( 'rolesTable' ) ] ; if ( isset ( $ userRoles [ 0 ] [ 'id' ] ) ) { $ userRoles = Hash :: extract ( $ userRoles , '{n}.id' ) ; } return $ this -> _mapped ( ( array ) $ userRoles ) ; } // Multi-role from session via pivot table $ pivotTableName = $ this -> getConfig ( 'pivotTable' ) ; if ( ! $ pivotTableName ) { list ( , $ rolesTableName ) = pluginSplit ( $ this -> getConfig ( 'rolesTable' ) ) ; list ( , $ usersTableName ) = pluginSplit ( $ this -> getConfig ( 'usersTable' ) ) ; $ tables = [ $ usersTableName , $ rolesTableName ] ; asort ( $ tables ) ; $ pivotTableName = implode ( '' , $ tables ) ; } if ( isset ( $ user [ $ pivotTableName ] ) ) { $ userRoles = $ user [ $ pivotTableName ] ; if ( isset ( $ userRoles [ 0 ] [ $ this -> getConfig ( 'roleColumn' ) ] ) ) { $ userRoles = Hash :: extract ( $ userRoles , '{n}.' . $ this -> getConfig ( 'roleColumn' ) ) ; } return $ this -> _mapped ( ( array ) $ userRoles ) ; } // Multi-role from DB: load the pivot table $ roles = $ this -> _getRolesFromDb ( $ pivotTableName , $ user [ $ this -> getConfig ( 'idColumn' ) ] ) ; if ( ! $ roles ) { return [ ] ; } return $ this -> _mapped ( $ roles ) ; }
Returns a list of all roles belonging to the authenticated user.

Lookup in the following order:
- single role id using the roleColumn in single-role mode
- direct lookup in the pivot table (to support both Configure and Model
in multi-role mode)

@param array $user The user to get the roles for
@return array List with all role ids belonging to the user
@throws \Cake\Core\Exception\Exception
Returns a list of all roles belonging to the authenticated user .