src/Repository/ItemRepository.php
public function findByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('i')
                     ->from(Item::class, 'i');

        $index = 0;
        $conditions = [];
        foreach ($namesByTypes as $type => $names) {
            $conditions[] = '(i.type = :type' . $index . ' AND i.name IN (:names' . $index . '))';
            $queryBuilder->setParameter('type' . $index, $type)
                         ->setParameter('names' . $index, array_values($names));
            ++$index;
        }

        $result = [];
        if ($index > 0) {
            $queryBuilder->andWhere('(' . implode(' OR ', $conditions) . ')');

            if (count($modCombinationIds) > 0) {
                $queryBuilder->innerJoin('i.modCombinations', 'mc')
                             ->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }
            $result = $queryBuilder->getQuery()->getResult();
        }
        return $result;
    }
public function findByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
    {
        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select('i')
                     ->from(Item::class, 'i');

        $index = 0;
        $conditions = [];
        foreach ($namesByTypes as $type => $names) {
            $conditions[] = '(i.type = :type' . $index . ' AND i.name IN (:names' . $index . '))';
            $queryBuilder->setParameter('type' . $index, $type)
                         ->setParameter('names' . $index, array_values($names));
            ++$index;
        }

        $result = [];
        if ($index > 0) {
            $queryBuilder->andWhere('(' . implode(' OR ', $conditions) . ')');

            if (count($modCombinationIds) > 0) {
                $queryBuilder->innerJoin('i.modCombinations', 'mc')
                             ->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }
            $result = $queryBuilder->getQuery()->getResult();
        }
        return $result;
    }
public function findByTypesAndNames ( array $ namesByTypes , array $ modCombinationIds = [ ] ) : array { $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( 'i' ) -> from ( Item :: class , 'i' ) ; $ index = 0 ; $ conditions = [ ] ; foreach ( $ namesByTypes as $ type => $ names ) { $ conditions [ ] = '(i.type = :type' . $ index . ' AND i.name IN (:names' . $ index . '))' ; $ queryBuilder -> setParameter ( 'type' . $ index , $ type ) -> setParameter ( 'names' . $ index , array_values ( $ names ) ) ; ++ $ index ; } $ result = [ ] ; if ( $ index > 0 ) { $ queryBuilder -> andWhere ( '(' . implode ( ' OR ' , $ conditions ) . ')' ) ; if ( count ( $ modCombinationIds ) > 0 ) { $ queryBuilder -> innerJoin ( 'i.modCombinations' , 'mc' ) -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } $ result = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; } return $ result ; }
Finds the items with the specified types and names.
@param array|string[][] $namesByTypes
@param array|int[] $modCombinationIds
@return array|Item[]
Finds the items with the specified types and names .