protected function convertValueIds($valueResult, &$counter = null)
    {
        $result      = [];
        $aliases     = [];
        $idColumn    = $this->getIdColumn();
        $aliasColumn = $this->getAliasColumn();
        while ($row = $valueResult->fetch(\PDO::FETCH_OBJ)) {
            $valueId           = $row->$idColumn;
            $aliases[$valueId] = $row->$aliasColumn;
            $result[]          = $valueId;
        }

        if (($counter !== null) && !empty($result)) {
            $statement = $this->getConnection()->createQueryBuilder()
                ->select('value_id', 'COUNT(value_id) as mm_count')
                ->from('tl_metamodel_tag_relation')
                ->where('att_id=:att')
                ->andWhere('value_id IN (:values)')
                ->groupBy('item_id')
                ->setParameter('att', $this->get('id'))
                ->setParameter('values', $result, Connection::PARAM_STR_ARRAY)
                ->execute()
                ->fetch(\PDO::FETCH_OBJ);

            $amount  = $statement->mm_count;
            $valueId = $statement->value_id;
            $alias   = $aliases[$valueId];

            $counter[$valueId] = $amount;
            $counter[$alias]   = $amount;
        }

        return $result;
    }