Your IP : 216.73.217.79


Current Path : /var/www/v3.cesa.co.za/src/ContentBundle/Repository/
Upload File :
Current File : /var/www/v3.cesa.co.za/src/ContentBundle/Repository/FormItemCompletedRepository.php

<?php

namespace App\ContentBundle\Repository;

use App\ContentBundle\Entity\FormCompleted;
use App\ContentBundle\Entity\FormItemCompleted;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
 * @extends ServiceEntityRepository<FormItemCompleted>
 *
 * @method FormItemCompleted|null find($id, $lockMode = null, $lockVersion = null)
 * @method FormItemCompleted|null findOneBy(array $criteria, array $orderBy = null)
 * @method FormItemCompleted[]    findAll()
 * @method FormItemCompleted[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
 */
class FormItemCompletedRepository extends ServiceEntityRepository {

    public function __construct(ManagerRegistry $registry) {
        parent::__construct($registry, FormItemCompleted::class);
    }

    function findByFormCompleted(FormCompleted $formCompleted, $excludeFormItemTypes = array()) {

        $qb = $this->createQueryBuilder('fit')
                ->join('fit.form_item', 'fi')
                ->join('fi.form_item_type', 'fitype')
                ->join('fi.forms', 'fif')
                ->join('fit.form_completed', 'fc')
                ->where('fc.id = :formCompletedId')
                ->setParameter('formCompletedId', $formCompleted->getId())
                ->orderBy('fif.order_by')
        ;

        if (count($excludeFormItemTypes) > 0) {
            $qb->andWhere('fitype.id NOT IN (:excludedTypes)')
                    ->setParameter('excludedTypes', $excludeFormItemTypes);
        }

        return $qb->getQuery()->execute();
    }
}