/** * @param $fromIndex * @param $toIndex * @param Step[] $steps * @throws \Exception */ private function stepDown($fromIndex, $toIndex, $steps) { for ($i = $fromIndex; $i > $toIndex; $i--) { if (!$steps[$i]->canBeUndone()) { throw new \Exception('Cannot migrate down. Step [' . get_class($steps[$i]) . '] cannot be undone.'); } } for ($i = $fromIndex; $i > $toIndex; $i--) { $this->dispatcher->fire(new MigrateDownEvent($steps[$i])); $steps[$i]->down(); } }
protected function fire(CollectionEvent $event) { if ($this->dispatcher) { $this->dispatcher->fire($event); } }
private function whenIFire($event) { $this->dispatcher->fire(new $event()); }