public function getUpsertDtoByCriteria(
        array $criteria,
        NewUpsertDtoDataModifierInterface $modifier
    ): TemplateEntityDto {
        $entity = $this->repository->findOneBy($criteria);
        if ($entity === null) {
            $dto = $this->dtoFactory->create();
            $modifier->addDataToNewlyCreatedDto($dto);

            return $dto;
        }

        return $this->dtoFactory->createDtoFromTemplateEntity($entity);
    }