setName('twitter-bot:run') ->addOption('event-path', null, InputOption::VALUE_REQUIRED); ; } /** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getContainer(); $ting = $container->get('ting'); $runner = new Runner( $ting->get(PlanningRepository::class), $ting->get(TalkRepository::class), $ting->get(EventRepository::class), $ting->get(SpeakerRepository::class), $ting->get(TweetRepository::class), $container->get(\TwitterAPIExchange::class) ); $runner->execute($this->getEventFilter($input)); } /** * @param InputInterface $input * * @return null */ protected function getEventFilter(InputInterface $input) { if (null === ($eventPath = $input->getOption('event-path'))) { return null; } $event = $this ->getContainer() ->get('ting') ->get(EventRepository::class) ->getByPath($eventPath) ; if (null === $event) { throw new \InvalidArgumentException("L'événement sur lequel filter n'a pas été trouvé"); } return $event; } }