/** * @param SummitEvent $event * @throws EntityValidationException */ public function validateBlackOutTimesAndTimes(SummitEvent $event) { // validate blackout times and speaker conflict $event_on_timeframe = $this->event_repository->getPublishedByTimeFrame(intval($event->SummitID), $event->getStartDate(), $event->getEndDate()); foreach ($event_on_timeframe as $c_event) { // if the published event is BlackoutTime or if there is a BlackoutTime event in this timeframe if (!$event->Location()->overridesBlackouts() && ($event->Type()->BlackoutTimes || $c_event->Type()->BlackoutTimes) && $event->ID != $c_event->ID) { throw new EntityValidationException(sprintf("You can't publish Event (%s) %s on this timeframe, it conflicts with (%s) %s.", $event->ID, $event->Title, $c_event->ID, $c_event->Title)); } // if trying to publish an event on a slot occupied by another event if (intval($event->LocationID) == $c_event->LocationID && $event->ID != $c_event->ID) { throw new EntityValidationException(sprintf("You can't publish Event (%s) %s on this timeframe, it conflicts with (%s) %s.", $event->ID, $event->Title, $c_event->ID, $c_event->Title)); } // validate speaker conflict if ($event instanceof Presentation && $c_event instanceof Presentation && $event->ID != $c_event->ID) { foreach ($event->Speakers() as $speaker) { if ($c_event->Speakers()->find('ID', $speaker->ID)) { throw new EntityValidationException(sprintf("You can't publish Event %s (%s) on this timeframe, speaker %s its presention in room %s at this time.", $event->Title, $event->ID, $speaker->getName(), $c_event->getLocationName())); } } } } }