亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

選擇輸入 TYPO3 v9 Symfony 命令

選擇輸入 TYPO3 v9 Symfony 命令

PHP
慕的地6264312 2023-10-21 09:58:46
我想在 TYPO3 v9 中創建一個調度程序命令,問題是,我不知道也無法找到如何進行選擇輸入。這就是我所擁有的:/** * Basic configuration(s) for the command. */protected function configure(): void{    $this->setName('WiRo Workflow')        ->setDescription('Sendet eine E-Mail an den Redakteur, wenn Inhaltselemente l?nger als 6 Monate nicht bearbeitet wurden')        ->addArgument('mailFrom', InputArgument::REQUIRED, 'Absender-Adresse')        ->addArgument('mailFromName', InputArgument::REQUIRED,'Absender-Name')        ->addArgument('mailTo', InputArgument::OPTIONAL, 'Empf?nger-Adresse (nur für Chefredakteure und Administratoren)')        ->addOption(            'colors',            ['blue', 'red'],            InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,            'Which colors do you like?',            ['blue', 'red']        )        ->addOption('optionTV', null, InputOption::VALUE_OPTIONAL, 'Benachrichtigung an: Themenverantwortlicher')        ->addOption('optionAdmin', null, InputOption::VALUE_NONE, 'admin')        ->addOption('optionAdminAct', null, InputOption::VALUE_NONE, 'Benachrichtigung an: Chefredakteur und Administratoren (Aktualisierung)')        ->addArgument('mailTimeToCheck', InputArgument::OPTIONAL, 'Anzahl Monate der Seiten, die zu prüfen sind:')        ->addArgument('urlMandant', InputArgument::OPTIONAL, 'URL des Mandanten')        ->addArgument('pageContact', InputArgument::OPTIONAL, 'Themenverantwortliche beziehen aus:')        ->addArgument('rootPageID', InputArgument::OPTIONAL, 'Root-Page')        ->addArgument('excludePages', InputArgument::OPTIONAL, 'Auszuschlie?ende Seiten (Komma separierte Liste)')        ->addArgument('mailSignature', InputArgument::OPTIONAL, 'Mail-Signatur');}
查看完整描述

1 回答

?
白衣染霜花

TA貢獻1796條經驗 獲得超10個贊

您不能將用戶選擇問題放在命令選項上...,而是必須使用帶有 ChoiceQuestion 對象的幫助器的詢問方法來


在你的指揮下


use Symfony\Component\Console\Question\ChoiceQuestion;


// ...

/**

 * Basic configuration(s) for the command.

 */

protected function configure(): void

{

    $this->setName('WiRo Workflow')

        ->setDescription('Sendet eine E-Mail an den Redakteur, wenn Inhaltselemente l?nger als 6 Monate nicht bearbeitet wurden')

        ->addArgument('mailFrom', InputArgument::REQUIRED, 'Absender-Adresse')

        ->addArgument('mailFromName', InputArgument::REQUIRED,'Absender-Name')

        ->addArgument('mailTo', InputArgument::OPTIONAL, 'Empf?nger-Adresse (nur für Chefredakteure und Administratoren)')

        ->addOption('optionTV', null, InputOption::VALUE_OPTIONAL, 'Benachrichtigung an: Themenverantwortlicher')

        ->addOption('optionAdmin', null, InputOption::VALUE_NONE, 'admin')

        ->addOption('optionAdminAct', null, InputOption::VALUE_NONE, 'Benachrichtigung an: Chefredakteur und Administratoren (Aktualisierung)')

        ->addArgument('mailTimeToCheck', InputArgument::OPTIONAL, 'Anzahl Monate der Seiten, die zu prüfen sind:')

        ->addArgument('urlMandant', InputArgument::OPTIONAL, 'URL des Mandanten')

        ->addArgument('pageContact', InputArgument::OPTIONAL, 'Themenverantwortliche beziehen aus:')

        ->addArgument('rootPageID', InputArgument::OPTIONAL, 'Root-Page')

        ->addArgument('excludePages', InputArgument::OPTIONAL, 'Auszuschlie?ende Seiten (Komma separierte Liste)')

        ->addArgument('mailSignature', InputArgument::OPTIONAL, 'Mail-Signatur');

}


protected function execute(InputInterface $input, OutputInterface $output): int

{

    //...


    $helper = $this->getHelper('question');

    $question = new ChoiceQuestion(

        'Which colors do you like?',

        ['blue', 'red'],

        0 // default is blue

    );


    $question->setErrorMessage('Color %s is invalid.');


    $color = $helper->ask($input, $output, $question);

    $output->writeln('You have just selected: ' . $color);


    // doSomething with $color



    return 0;

}

//...


查看完整回答
反對 回復 2023-10-21
  • 1 回答
  • 0 關注
  • 130 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號