Example #1
0
 /**
  * 绑定ui
  * @param MagicHand $magicHand
  * @param OutputInterface $output
  */
 protected function bindEventsForUi(MagicHand $magicHand, OutputInterface $output)
 {
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_BEGIN, function (Event $event) use($output) {
         $images = $event->getArgument('images');
         $progressBar = new ProgressBar($output, count($images));
         $output->writeln("Magic Hand started and will be performed {$progressBar->getMaxSteps()} images");
         $output->write(PHP_EOL);
         $progressBar->start();
         $this->progressBar = $progressBar;
     });
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_PROCESS, function (Event $event) use($output) {
         $this->progressBar->advance(1);
     });
     $magicHand->getDispatcher()->bind(MagicHand::EVENT_END, function (Event $event) use($output) {
         $this->progressBar->finish();
         $output->writeln(PHP_EOL);
         $output->writeln("Work ok");
     });
 }