Example #1
0
 /**
  * @param bool $onlyFinal
  * @param Project $project
  *
  * @return Calendar[]
  */
 public function findCalendarByProject(Project $project, $onlyFinal = true)
 {
     $calendar = [];
     /**
      * Add the calendar items from the project
      */
     foreach ($project->getProjectCalendar() as $calendarItem) {
         if (!$onlyFinal || $calendarItem->getCalendar()->getFinal() === Calendar::FINAL_FINAL) {
             $calendar[$calendarItem->getCalendar()->getId()] = $calendarItem->getCalendar();
         }
     }
     foreach ($project->getCall()->getCalendar() as $calendarItem) {
         if (!$onlyFinal || $calendarItem->getFinal() === Calendar::FINAL_FINAL) {
             if ($calendarItem->getDateEnd() > new \DateTime()) {
                 $calendar[$calendarItem->getId()] = $calendarItem;
             }
         }
     }
     return $calendar;
 }