src/Attribute/TranslatedTags.php
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;
    }
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;
    }
Convert the value ids to a result array.

@param Statement  $valueResult The database result.

@param null|array $counter     The destination for the counter values.

@return int[] The value ids that are represented by the passed database statement.