/** * Creates a Timeline instance with all available versions. Those versions that have already been migrated will * be marked accordingly. * * @param \Baleen\Migrations\Version\VersionInterface[]|Linked $available * @param \Baleen\Migrations\Version\VersionInterface[]|Migrated $migrated * @return Timeline * @throws MigrationMissingException */ public function create($available, $migrated = []) { $collection = $this->prepareCollection($available, $migrated)->sort($this->comparator); $timeline = new Timeline($collection); $timeline->setEventDispatcher($this->dispatcher); return $timeline; }
/** * registerDomainEvent * * @param Timeline $timeline * @param callable $comparator * @param OutputInterface $output */ protected function registerDomainEvent(Timeline $timeline, callable $comparator, OutputInterface $output) { $domainDispatcher = $timeline->getEventDispatcher(); $domainDispatcher->addListener(EventInterface::COLLECTION_BEFORE, function (CollectionEvent $event) use($comparator, $output) { $first = $event->getCollection()->get('HEAD'); if (!$first) { $first = $event->getCollection()->first(); } $last = $event->getCollection()->last(); $b2tfVersion = new Version(20151021072800); if ($comparator($first, $b2tfVersion) < 0 && $comparator($last, $b2tfVersion) >= 0) { // we're crossing into the future! $output->writeln(['<info>+++ You\'re migrating past October 21st 2015 07:28 - #BackToTheFuture Day</info>', '<info>+++</info>', '<info>+++</info> <comment>"If you put your mind to it, you can accomplish anything." - Marty McFly</comment>', '<info>+++</info>', '<info>+++ Baleen welcomes you to the future!!</info>', '']); } }); }