src/Model/Table/GroupsTable.php
public function getUserGroups(string $userId, array $options = []): array
    {
        $query = $this->find('list', [
            'keyField' => 'id',
            'valueField' => 'name'
        ]);
        $query->matching('Users', function ($q) use ($userId) {
            return $q->where(['Users.id' => $userId]);
        });
        $query->applyOptions($options);

        return $query->toArray();
    }
public function getUserGroups(string $userId, array $options = []): array
    {
        $query = $this->find('list', [
            'keyField' => 'id',
            'valueField' => 'name'
        ]);
        $query->matching('Users', function ($q) use ($userId) {
            return $q->where(['Users.id' => $userId]);
        });
        $query->applyOptions($options);

        return $query->toArray();
    }
public function getUserGroups ( string $ userId , array $ options = [ ] ) : array { $ query = $ this -> find ( 'list' , [ 'keyField' => 'id' , 'valueField' => 'name' ] ) ; $ query -> matching ( 'Users' , function ( $ q ) use ( $ userId ) { return $ q -> where ( [ 'Users.id' => $ userId ] ) ; } ) ; $ query -> applyOptions ( $ options ) ; return $ query -> toArray ( ) ; }
Method that retrieves specified user's groups as list.

@param string $userId user id
@param mixed[] $options Query options
@return mixed[]
Method that retrieves specified user s groups as list .