/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $feeds = $input->getOption('feed'); $force = $input->getOption('force'); $interactive = $input->isInteractive(); $dispatcher = $this->sourceCleaner->getEventDispatcher(); // listen to clean event $dispatcher->addListener(IoEvents::PRE_CLEAN_SOURCE, function (SourceEvent $event) use($output) { $source = $event->getSource(); $output->writeln(sprintf('<fg=red>- %s:%s</>', $source->getFeed(), $source->getOriginalId())); }); $function = $this->getThresholdVotingFunction($input, $output, $force, $interactive); $voter = new ThresholdVoter($function, $dispatcher); if (!empty($feeds)) { $numCleaned = $this->cleanFeeds($voter, $feeds); } else { $numCleaned = $this->cleanAll($voter); } $output->writeln(sprintf('<info>%s</info> sources cleaned', $numCleaned)); return 0; }