entityManager = $entityManager; } /** * @param array $ids * * @return array */ public function findByDamIds(array $ids): array { $qb = $this->entityManager->createQueryBuilder(); $qb->select('cf') ->from(CommonFile::class, 'cf') ->where($qb->expr()->in('cf.idDam', $ids)) ->andWhere('cf.deletedAt IS NULL'); return $qb->getQuery() ->getResult(); } /** * @param int $templateId * @param string $fileTypeName * @param string $fileTypeExtension * * @return array */ public function findCommonIdsByTemplateIdAndFileTypeProperties(int $templateId, string $fileTypeName, string $fileTypeExtension): array { $qb = $this->entityManager->createQueryBuilder(); $qb->select('cf.idDam as commonFileId') ->from(CommonFile::class, 'cf') ->innerJoin('cf.templates', 't') ->innerJoin('cf.fileType', 'ft') ->where('cf.idDam IS NOT NULL') ->andWhere('cf.deletedAt IS NULL') ->andWhere('t.id = :id') ->andWhere('ft.name = :name') ->andWhere('ft.extension = :extension') ->andWhere('ft.deletedAt IS NULL') ->setParameters(["id" => $templateId, "name" => $fileTypeName, "extension" => $fileTypeExtension]); return $qb->getQuery()->getResult(); } }