rbac/DbManager.php
public function getRolesByUser($userGuid)
    {
        if (!isset($userGuid) || $userGuid === '') {
            return [];
        }
        
        if ($userGuid instanceof User) {
            $userGuid = $userGuid->getGUID();
        }

        $query = (new Query)->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_guid' => (string) $userGuid])
            ->andWhere(['b.type' => Item::TYPE_ROLE]);

        $roles = [];
        foreach ($query->all($this->db) as $row) {
            $roles[$row['name']] = $this->populateItem($row);
        }
        return $roles;
    }
public function getRolesByUser($userGuid)
    {
        if (!isset($userGuid) || $userGuid === '') {
            return [];
        }
        
        if ($userGuid instanceof User) {
            $userGuid = $userGuid->getGUID();
        }

        $query = (new Query)->select('b.*')
            ->from(['a' => $this->assignmentTable, 'b' => $this->itemTable])
            ->where('{{a}}.[[item_name]]={{b}}.[[name]]')
            ->andWhere(['a.user_guid' => (string) $userGuid])
            ->andWhere(['b.type' => Item::TYPE_ROLE]);

        $roles = [];
        foreach ($query->all($this->db) as $row) {
            $roles[$row['name']] = $this->populateItem($row);
        }
        return $roles;
    }
public function getRolesByUser ( $ userGuid ) { if ( ! isset ( $ userGuid ) || $ userGuid === '' ) { return [ ] ; } if ( $ userGuid instanceof User ) { $ userGuid = $ userGuid -> getGUID ( ) ; } $ query = ( new Query ) -> select ( 'b.*' ) -> from ( [ 'a' => $ this -> assignmentTable , 'b' => $ this -> itemTable ] ) -> where ( '{{a}}.[[item_name]]={{b}}.[[name]]' ) -> andWhere ( [ 'a.user_guid' => ( string ) $ userGuid ] ) -> andWhere ( [ 'b.type' => Item :: TYPE_ROLE ] ) ; $ roles = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ roles [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } return $ roles ; }
Get roles by user.
@param string|User $userGuid
@return array
Get roles by user .