src/Repository/IconRepository.php
public function findDataByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
    {
        $columns = [
            'i.id AS id',
            'IDENTITY(i.file) AS hash',
            'i.type AS type',
            'i.name AS name',
            'mc.order AS order'
        ];

        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select($columns)
                     ->from(Icon::class, 'i')
                     ->innerJoin('i.modCombination', 'mc');

        $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->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }

            $result = $this->mapIconDataResult($queryBuilder->getQuery()->getResult());
        }
        return $result;
    }
public function findDataByTypesAndNames(array $namesByTypes, array $modCombinationIds = []): array
    {
        $columns = [
            'i.id AS id',
            'IDENTITY(i.file) AS hash',
            'i.type AS type',
            'i.name AS name',
            'mc.order AS order'
        ];

        $queryBuilder = $this->entityManager->createQueryBuilder();
        $queryBuilder->select($columns)
                     ->from(Icon::class, 'i')
                     ->innerJoin('i.modCombination', 'mc');

        $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->andWhere('mc.id IN (:modCombinationIds)')
                             ->setParameter('modCombinationIds', array_values($modCombinationIds));
            }

            $result = $this->mapIconDataResult($queryBuilder->getQuery()->getResult());
        }
        return $result;
    }
public function findDataByTypesAndNames ( array $ namesByTypes , array $ modCombinationIds = [ ] ) : array { $ columns = [ 'i.id AS id' , 'IDENTITY(i.file) AS hash' , 'i.type AS type' , 'i.name AS name' , 'mc.order AS order' ] ; $ queryBuilder = $ this -> entityManager -> createQueryBuilder ( ) ; $ queryBuilder -> select ( $ columns ) -> from ( Icon :: class , 'i' ) -> innerJoin ( 'i.modCombination' , 'mc' ) ; $ 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 -> andWhere ( 'mc.id IN (:modCombinationIds)' ) -> setParameter ( 'modCombinationIds' , array_values ( $ modCombinationIds ) ) ; } $ result = $ this -> mapIconDataResult ( $ queryBuilder -> getQuery ( ) -> getResult ( ) ) ; } return $ result ; }
Finds the data of the specified entities.
@param array|string[][] $namesByTypes
@param array|int[] $modCombinationIds
@return array|IconData[]
Finds the data of the specified entities .