/** * @param array $types * * @return FeedTypeInterface[] */ protected function getTypes(array $types) { if (empty($types)) { return $this->exporter->getTypes(); } $result = []; foreach ($types as &$type) { $result[] = $this->exporter->getType($type); } return $result; }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $type = $this->exporter->getType($input->getArgument('type')); $file = $this->exporter->getFeedFilename($type); if (!file_exists($file)) { $output->writeln(sprintf('<error>Feed "%s" has not yet been exported</error>', $type->getName())); return 1; } $evaluationMethod = $input->getOption('evaluate'); $evaluationExpression = $input->getOption('expression'); if (!$evaluationMethod && $evaluationExpression) { $evaluationMethod = self::EVALUATE_EXPRESSION; } if (!$evaluationMethod) { $evaluationMethod = self::EVALUATE_COUNT; } list($results, $total) = $this->inspect($output, new \SplFileInfo($file), $input->getOption('filter')); switch ($evaluationMethod) { case self::EVALUATE_COUNT: if ($evaluationExpression) { throw new \InvalidArgumentException('You cannot use an expression when using count evaluation'); } $this->evaluateCount($output, $results, $total); break; case self::EVALUATE_EXPRESSION: $this->evaluateResult($output, $evaluationExpression, $results, $total); break; default: throw new \InvalidArgumentException(sprintf('Invalid evaluation method: %s', $evaluationMethod)); } return 0; }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $type = $this->exporter->getType($input->getArgument('type')); try { $this->validate($type, $output); } catch (\RuntimeException $exception) { $output->writeln(''); $output->writeln(sprintf('<error>%s</error>', $exception->getMessage())); $output->writeln(''); $output->writeln('Node:'); $output->writeln($this->currentItem); return 1; } $output->writeln(''); $output->writeln(sprintf('<info>Feed "%s" is valid!</info>', $type->getName())); return 0; }