/** * @param Import $import */ protected function removeItemLog(Import $import) { if (!$this->itemLogger) { return; } $this->itemLogger->removeLog($import); }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { if (null === ($import = $this->findImportById($input->getArgument('import')))) { $output->writeln(sprintf('<error>Import %d does not exist</error>', $input->getArgument('import'))); return 1; } $items = 0; $success = 0; $failed = 0; $skipped = 0; foreach ($this->itemLogger->getImportedItems($import) as $item) { $output->writeln(sprintf('<info>%s</info>:', $item['item'])); ++$items; foreach ($item as $key => $value) { if ($key === 'item') { continue; } $output->writeln(sprintf(' <info>%s</info>: <comment>%s</comment>', $key, $value)); } switch ($item['result']) { case 'success': $success++; break; case 'failed': $failed++; break; case 'skipped': $skipped++; break; } } $output->writeln(''); $output->writeln(sprintf('Imported <info>%s</info> items', $items)); $output->writeln(sprintf('- succes: <info>%s</info> (<info>%.2f%%</info>)', $success, $success / $items * 100)); $output->writeln(sprintf('- failed: <info>%s</info> (<info>%.2f%%</info>)', $failed, $failed / $items * 100)); $output->writeln(sprintf('- skipped: <info>%s</info> (<info>%.2f%%</info>)', $skipped, $skipped / $items * 100)); return 0; }