ChoiceQuestion example



    /** * @param string[] $locales * * @throws RuntimeException * * @return string */
    protected function askForAdminLocale($locales)
    {
        $question = new ChoiceQuestion('Please select your admin locale', $locales);
        $question->setErrorMessage('Locale %s is invalid.');

        $shopLocale = $this->IOHelper->ask($question);

        return $shopLocale;
    }

    /** * @param string[] $locales * * @return string */
$this->io = new SymfonyStyle($input$output);
        $helper = $this->getHelper('question');

        if ($input->getOption('sales-channel') && $input->getOption('all')) {
            $this->io->error('You can use either --sales-channel or --all, not both at the same time.');

            return self::INVALID;
        }

        if (!$themeName) {
            $question = new ChoiceQuestion('Please select a theme:', $this->getThemeChoices());
            $themeName = $helper->ask($input$output$question);
        }
        \assert(\is_string($themeName));

        /** @var SalesChannelCollection $salesChannels */
        $salesChannels = $this->salesChannelRepository->search(new Criteria()$this->context)->getEntities();

        if ($input->getOption('all')) {
            $selectedSalesChannel = $salesChannels;
        } else {
            if (!$salesChannelOption) {
                
/** @var PluginCollection $pluginCollection */
        $pluginCollection = $this->pluginRepo->search($criteria$context)->getEntities();

        if ($pluginCollection->count() <= 1) {
            return $pluginCollection;
        }

        $choiceAbort = 'Cancel.';
        $choiceSelect = sprintf('Select one Plugin to %s.', $lifecycleMethod);

        $choice = $io->askQuestion(
            new ChoiceQuestion(
                sprintf(
                    '%d plugins were found. How do you want to continue?',
                    $pluginCollection->count()
                ),
                [
                    sprintf('%s all of them.', $lifecycleMethod),
                    $choiceSelect,
                    $choiceAbort,
                ]
            )
        );

        
Home | Imprint | This part of the site doesn't use cookies.