/** * 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>', '']); } }); }