eZ\Publish\Core\Persistence\Legacy\User\Role\Gateway\DoctrineDatabase::fetchUserGroups PHP Method

fetchUserGroups() protected method

This method will return Content ids of all ancestor Locations for the given $userId. Note that not all of these might be used as user groups, but we will need to check all of them.
protected fetchUserGroups ( integer $userId ) : array
$userId integer
return array
    protected function fetchUserGroups($userId)
    {
        $query = $this->handler->createSelectQuery();
        $query->select($this->handler->quoteColumn('path_string', 'ezcontentobject_tree'))->from($this->handler->quoteTable('ezcontentobject_tree'))->where($query->expr->eq($this->handler->quoteColumn('contentobject_id', 'ezcontentobject_tree'), $query->bindValue($userId)));
        $statement = $query->prepare();
        $statement->execute();
        $paths = $statement->fetchAll(\PDO::FETCH_COLUMN);
        $nodeIDs = array_unique(array_reduce(array_map(function ($pathString) {
            return array_filter(explode('/', $pathString));
        }, $paths), 'array_merge_recursive', array()));
        if (empty($nodeIDs)) {
            return array();
        }
        $query = $this->handler->createSelectQuery();
        $query->select($this->handler->quoteColumn('id', 'ezcontentobject'))->from($this->handler->quoteTable('ezcontentobject_tree'))->innerJoin($this->handler->quoteTable('ezcontentobject'), $query->expr->eq($this->handler->quoteColumn('id', 'ezcontentobject'), $this->handler->quoteColumn('contentobject_id', 'ezcontentobject_tree')))->where($query->expr->in($this->handler->quoteColumn('node_id', 'ezcontentobject_tree'), $nodeIDs));
        $statement = $query->prepare();
        $statement->execute();
        return $statement->fetchAll(\PDO::FETCH_COLUMN);
    }