예제 #1
0
 /**
  * @param  Calendar         $calendar
  * @return Entity\Contact[]
  */
 public function findPossibleContactByCalendar(Calendar $calendar)
 {
     /**
      * Use the contactQueryBuilder and exclude the ones which are already present based on the roles
      */
     $findContactByProjectIdQueryBuilder = $this->findContactByProjectIdQueryBuilder();
     //Find the reviewers
     $findReviewContactByProjectQueryBuilder = $this->getEntityManager()->getRepository('Project\\Entity\\Review\\Review')->findReviewContactByProjectQueryBuilder();
     //Remove all the contacts which are already in the project as associate or otherwise affected
     $findContactByProjectIdQueryBuilder->andWhere($findContactByProjectIdQueryBuilder->expr()->notIn('c', $findReviewContactByProjectQueryBuilder->getDQL()));
     $findContactByProjectIdQueryBuilder->setParameter(1, $calendar->getProjectCalendar()->getProject()->getId());
     $findContactByProjectIdQueryBuilder->setParameter('project', $calendar->getProjectCalendar()->getProject());
     $findContactByProjectIdQueryBuilder->addOrderBy('c.lastName', 'ASC');
     return $findContactByProjectIdQueryBuilder->getQuery()->getResult();
 }
예제 #2
0
 /**
  * @param Entity\Calendar $calendar
  *
  * @return Entity\Contact[]
  */
 public function findGeneralCalendarContactByCalendar(Entity\Calendar $calendar)
 {
     $qb = $this->_em->createQueryBuilder();
     $qb->select('cc');
     $qb->from("Calendar\\Entity\\Contact", 'cc');
     $qb->join('cc.contact', 'contact');
     $qb->andWhere('cc.calendar = :calendar');
     //Remove all the contacts which are already in the project as associate or otherwise affected
     $findContactByProjectIdQueryBuilder = $this->_em->getRepository('Contact\\Entity\\Contact')->findContactByProjectIdQueryBuilder();
     $qb->andWhere($qb->expr()->notIn('cc.contact', $findContactByProjectIdQueryBuilder->getDQL()));
     $qb->setParameter(1, $calendar->getProjectCalendar()->getProject()->getId());
     $qb->setParameter('calendar', $calendar);
     $qb->addOrderBy('contact.lastName', 'ASC');
     return $qb->getQuery()->getResult();
 }
예제 #3
0
 /**
  * @return bool
  */
 public function isEmpty()
 {
     return is_null($this->calendar) || is_null($this->calendar->getId());
 }
예제 #4
0
 /**
  * @param Calendar $calendar
  *
  * @return Contact[]
  *
  * @throws \Exception
  */
 public function findPossibleContactByCalendar(Calendar $calendar)
 {
     if (is_null($calendar->getProjectCalendar())) {
         throw new \Exception("A projectCalendar is required to find the contacts");
     }
     return $this->getEntityManager()->getRepository(Contact::class)->findPossibleContactByCalendar($calendar);
 }