setName('twitter-list:create') ->addArgument('event-path', null, InputArgument::REQUIRED) ->addOption('custom-name', null, InputOption::VALUE_REQUIRED, 'Use this value as list name instead of the event title') ; } /** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $container = $this->getContainer(); $ting = $container->get('ting'); $event = $this->getEventFilter($input); $twitterListCreator = new ListCreator($container->get(\TwitterAPIExchange::class), $ting->get(SpeakerRepository::class)); $twitterListCreator->create($event, $input->getOption('custom-name')); } /** * @param InputInterface $input * * @return null */ protected function getEventFilter(InputInterface $input) { $eventPath = $input->getArgument('event-path'); $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; } }