protected function calculateFilterOptionsCount($items, &$amountArray, $idList)
    {
        $builder = $this
            ->getConnection()
            ->createQueryBuilder()
            ->select('value_id')
            ->addSelect('COUNT(item_id) AS amount')
            ->from('tl_metamodel_tag_relation')
            ->where('att_id=:attId')
            ->setParameter('attId', $this->get('id'))
            ->groupBy('value_id');

        if (0 < $items->getCount()) {
            $ids = [];
            foreach ($items as $item) {
                $ids[] = $item->get('id');
            }
            $builder
                ->andWhere('value_id IN (:valueIds)')
                ->setParameter('valueIds', $ids, Connection::PARAM_STR_ARRAY);
            if ($idList && \is_array($idList)) {
                $builder
                    ->andWhere('item_id IN (:itemIds)')
                    ->setParameter('itemIds', $idList, Connection::PARAM_STR_ARRAY);
            }
        }

        $counts = $builder->execute();
        foreach ($counts->fetchAll(\PDO::FETCH_ASSOC) as $count) {
            $amountArray[$count['value_id']] = $count['amount'];
        }
    }
protected function calculateFilterOptionsCount($items, &$amountArray, $idList)
    {
        $builder = $this
            ->getConnection()
            ->createQueryBuilder()
            ->select('value_id')
            ->addSelect('COUNT(item_id) AS amount')
            ->from('tl_metamodel_tag_relation')
            ->where('att_id=:attId')
            ->setParameter('attId', $this->get('id'))
            ->groupBy('value_id');

        if (0 < $items->getCount()) {
            $ids = [];
            foreach ($items as $item) {
                $ids[] = $item->get('id');
            }
            $builder
                ->andWhere('value_id IN (:valueIds)')
                ->setParameter('valueIds', $ids, Connection::PARAM_STR_ARRAY);
            if ($idList && \is_array($idList)) {
                $builder
                    ->andWhere('item_id IN (:itemIds)')
                    ->setParameter('itemIds', $idList, Connection::PARAM_STR_ARRAY);
            }
        }

        $counts = $builder->execute();
        foreach ($counts->fetchAll(\PDO::FETCH_ASSOC) as $count) {
            $amountArray[$count['value_id']] = $count['amount'];
        }
    }
protected function calculateFilterOptionsCount ( $ items , & $ amountArray , $ idList ) { $ builder = $ this -> getConnection ( ) -> createQueryBuilder ( ) -> select ( 'value_id' ) -> addSelect ( 'COUNT(item_id) AS amount' ) -> from ( 'tl_metamodel_tag_relation' ) -> where ( 'att_id=:attId' ) -> setParameter ( 'attId' , $ this -> get ( 'id' ) ) -> groupBy ( 'value_id' ) ; if ( 0 < $ items -> getCount ( ) ) { $ ids = [ ] ; foreach ( $ items as $ item ) { $ ids [ ] = $ item -> get ( 'id' ) ; } $ builder -> andWhere ( 'value_id IN (:valueIds)' ) -> setParameter ( 'valueIds' , $ ids , Connection :: PARAM_STR_ARRAY ) ; if ( $ idList && \ is_array ( $ idList ) ) { $ builder -> andWhere ( 'item_id IN (:itemIds)' ) -> setParameter ( 'itemIds' , $ idList , Connection :: PARAM_STR_ARRAY ) ; } } $ counts = $ builder -> execute ( ) ; foreach ( $ counts -> fetchAll ( \ PDO :: FETCH_ASSOC ) as $ count ) { $ amountArray [ $ count [ 'value_id' ] ] = $ count [ 'amount' ] ; } }
Calculate the amount how often each value has been assigned.

@param IItems $items       The item list containing the values.

@param array  $amountArray The target array to where the counters shall be stored to.

@param array  $idList      The ids of items.

@return void
Calculate the amount how often each value has been assigned .