private function determineCount($items, &$count, $idList)
    {
        $usedOptionsIdList = \array_unique(\array_filter(\array_map(
            function ($item) {
                /** @var IItem $item */
                return $item->get('id');
            },
            \iterator_to_array($items)
        )));

        if (empty($usedOptionsIdList)) {
            return;
        }

        $valueCol = $this->getColName();
        $query    = $this->connection->createQueryBuilder()
            ->select($this->getColName())
            ->addSelect(\sprintf('COUNT(%s) AS count', $this->getColName()))
            ->from($this->getMetaModel()->getTableName())
            ->where($this->getColName() . ' IN (:ids)')
            ->groupBy($this->getColName())
            ->setParameter('ids', $usedOptionsIdList, Connection::PARAM_STR_ARRAY);
        if ($idList !== null && !empty($idList)) {
            $query
                ->andWhere('id IN (:idList)')
                ->setParameter('idList', $idList, Connection::PARAM_STR_ARRAY);
        }
        $query = $query->execute();

        while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
            $count[$row->{$valueCol}] = $row->count;
        }
    }
private function determineCount($items, &$count, $idList)
    {
        $usedOptionsIdList = \array_unique(\array_filter(\array_map(
            function ($item) {
                /** @var IItem $item */
                return $item->get('id');
            },
            \iterator_to_array($items)
        )));

        if (empty($usedOptionsIdList)) {
            return;
        }

        $valueCol = $this->getColName();
        $query    = $this->connection->createQueryBuilder()
            ->select($this->getColName())
            ->addSelect(\sprintf('COUNT(%s) AS count', $this->getColName()))
            ->from($this->getMetaModel()->getTableName())
            ->where($this->getColName() . ' IN (:ids)')
            ->groupBy($this->getColName())
            ->setParameter('ids', $usedOptionsIdList, Connection::PARAM_STR_ARRAY);
        if ($idList !== null && !empty($idList)) {
            $query
                ->andWhere('id IN (:idList)')
                ->setParameter('idList', $idList, Connection::PARAM_STR_ARRAY);
        }
        $query = $query->execute();

        while ($row = $query->fetch(\PDO::FETCH_ASSOC)) {
            $count[$row->{$valueCol}] = $row->count;
        }
    }
private function determineCount ( $ items , & $ count , $ idList ) { $ usedOptionsIdList = \ array_unique ( \ array_filter ( \ array_map ( function ( $ item ) { /** @var IItem $item */ return $ item -> get ( 'id' ) ; } , \ iterator_to_array ( $ items ) ) ) ) ; if ( empty ( $ usedOptionsIdList ) ) { return ; } $ valueCol = $ this -> getColName ( ) ; $ query = $ this -> connection -> createQueryBuilder ( ) -> select ( $ this -> getColName ( ) ) -> addSelect ( \ sprintf ( 'COUNT(%s) AS count' , $ this -> getColName ( ) ) ) -> from ( $ this -> getMetaModel ( ) -> getTableName ( ) ) -> where ( $ this -> getColName ( ) . ' IN (:ids)' ) -> groupBy ( $ this -> getColName ( ) ) -> setParameter ( 'ids' , $ usedOptionsIdList , Connection :: PARAM_STR_ARRAY ) ; if ( $ idList !== null && ! empty ( $ idList ) ) { $ query -> andWhere ( 'id IN (:idList)' ) -> setParameter ( 'idList' , $ idList , Connection :: PARAM_STR_ARRAY ) ; } $ query = $ query -> execute ( ) ; while ( $ row = $ query -> fetch ( \ PDO :: FETCH_ASSOC ) ) { $ count [ $ row -> { $ valueCol } ] = $ row -> count ; } }
Determine the option count for the passed items.

@param IItems|IItem[] $items The item collection to convert.

@param null|string[]  $count The counter array.

@param array          $idList The id list for the subselect.

@return void
Determine the option count for the passed items .