/**
  * Generates the output for the report.
  *
  * @param ConsoleLoggerInterface $logger
  */
 public function generate(ConsoleLoggerInterface $logger)
 {
     $logLevel = LogLevel::NOTICE;
     $style = TitleBlock::STYLE_SUCCESS;
     if ($this->eventDataCollector->hasCountedFailedEvents()) {
         $logLevel = LogLevel::ERROR;
         $style = TitleBlock::STYLE_FAILURE;
     } elseif ($this->eventDataCollector->hasCountedLogLevel(LogLevel::EMERGENCY) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ALERT) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::CRITICAL) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::ERROR) || $this->eventDataCollector->hasCountedLogLevel(LogLevel::WARNING)) {
         $logLevel = LogLevel::WARNING;
         $style = TitleBlock::STYLE_ERRORED_SUCCESS;
     }
     $output = $logger->getOutput($logLevel);
     $titleBlock = new TitleBlock($output, $this->messages[$style], $style);
     $titleBlock->render();
     $dataCollectorsData = array();
     foreach ($this->dataCollectors as $dataCollector) {
         $data = $dataCollector->getData($logger->getVerbosity());
         foreach ($data as $label => $value) {
             $dataCollectorsData[] = array($label, $value);
         }
     }
     $table = new Table($output);
     $table->setRows($dataCollectorsData);
     $table->setStyle('symfony-style-guide');
     $table->render();
     $output->writeln('');
 }
 /**
  * {@inheritdoc}
  */
 public function deploy($version, $stage)
 {
     $successfulDeploy = true;
     $hosts = $this->configuration->getHostsByStage($stage);
     foreach ($hosts as $host) {
         $exception = null;
         $deployEventName = AccompliEvents::DEPLOY_RELEASE;
         $deployCompleteEventName = AccompliEvents::DEPLOY_RELEASE_COMPLETE;
         $deployFailedEventName = AccompliEvents::DEPLOY_RELEASE_FAILED;
         $title = new Title($this->logger->getOutput(), sprintf('Deploying release "%s" to "%s":', $version, $host->getHostname()));
         $title->render();
         try {
             $this->eventDispatcher->dispatch(AccompliEvents::CREATE_CONNECTION, new HostEvent($host));
             $workspaceEvent = new WorkspaceEvent($host);
             $this->eventDispatcher->dispatch(AccompliEvents::GET_WORKSPACE, $workspaceEvent);
             $workspace = $workspaceEvent->getWorkspace();
             if ($workspace instanceof Workspace) {
                 $prepareDeployReleaseEvent = new PrepareDeployReleaseEvent($workspace, $version);
                 $this->eventDispatcher->dispatch(AccompliEvents::PREPARE_DEPLOY_RELEASE, $prepareDeployReleaseEvent);
                 $release = $prepareDeployReleaseEvent->getRelease();
                 if ($release instanceof Release) {
                     $currentRelease = $prepareDeployReleaseEvent->getCurrentRelease();
                     if ($currentRelease instanceof Release && Comparator::lessThan($release->getVersion(), $currentRelease->getVersion())) {
                         $deployEventName = AccompliEvents::ROLLBACK_RELEASE;
                         $deployCompleteEventName = AccompliEvents::ROLLBACK_RELEASE_COMPLETE;
                         $deployFailedEventName = AccompliEvents::ROLLBACK_RELEASE_FAILED;
                     }
                     $deployReleaseEvent = new DeployReleaseEvent($release, $currentRelease);
                     $this->eventDispatcher->dispatch($deployEventName, $deployReleaseEvent);
                     $this->eventDispatcher->dispatch($deployCompleteEventName, $deployReleaseEvent);
                     continue;
                 }
                 throw new RuntimeException(sprintf('No task configured to initialize release version "%s" for deployment.', $version));
             }
             throw new RuntimeException('No task configured to initialize the workspace.');
         } catch (Exception $exception) {
         }
         $successfulDeploy = false;
         $failedEvent = new FailedEvent($this->eventDispatcher->getLastDispatchedEventName(), $this->eventDispatcher->getLastDispatchedEvent(), $exception);
         $this->eventDispatcher->dispatch($deployFailedEventName, $failedEvent);
     }
     return $successfulDeploy;
 }