/** * {@inheritdoc} */ public function add(EventInterface $newEvent, array $events) { foreach ($events as $event) { if ($newEvent->getInterval()->isDuring($event->getInterval())) { throw CalendarEventException::eventOverlap($newEvent); } } return parent::add($newEvent, $events); }
/** * {@inheritdoc} */ public function remove(EventInterface $removedEvent, array $events) { $index = 0; foreach ($events as $event) { if ($removedEvent->isEquals($event)) { array_splice($events, $index, 1); } else { $index++; } } return $events; }
public function isEquals(EventInterface $event) { return $this->interval->getBegin()->isEquals($event->getInterval()->getBegin()) && $this->interval->getEnd()->isEquals($event->getInterval()->getEnd()); }