本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand::interact方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerAwareCommand::interact方法的具体用法?PHP ContainerAwareCommand::interact怎么用?PHP ContainerAwareCommand::interact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
的用法示例。
在下文中一共展示了ContainerAwareCommand::interact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: interact
protected function interact(InputInterface $input, OutputInterface $output)
{
$helper = $this->getHelper('question');
if (trim($input->getOption('name')) == '') {
$question = new Question\Question('Please enter the client name: ');
$question->setValidator(function ($value) {
if (trim($value) == '') {
throw new \Exception('The client name can not be empty');
}
$doctrine = $this->getContainer()->get('doctrine');
$client = $doctrine->getRepository('AppBundle:Client')->findOneBy(['name' => $value]);
if ($client instanceof \AppBundle\Entity\Client) {
throw new \Exception('The client name must be unique');
}
return $value;
});
$question->setMaxAttempts(5);
$input->setOption('name', $helper->ask($input, $output, $question));
}
$grants = $input->getOption('grant-type');
if (!(is_array($grants) && count($grants))) {
$question = new Question\ChoiceQuestion('Please select the grant types (defaults to password and facebook_access_token): ', [\OAuth2\OAuth2::GRANT_TYPE_AUTH_CODE, \OAuth2\OAuth2::GRANT_TYPE_CLIENT_CREDENTIALS, \OAuth2\OAuth2::GRANT_TYPE_EXTENSIONS, \OAuth2\OAuth2::GRANT_TYPE_IMPLICIT, \OAuth2\OAuth2::GRANT_TYPE_REFRESH_TOKEN, \OAuth2\OAuth2::GRANT_TYPE_USER_CREDENTIALS, 'http://grants.api.schoolmanager.ledo.eu.org/facebook_access_token'], '5,6');
$question->setMultiselect(true);
$question->setMaxAttempts(5);
$input->setOption('grant-type', $helper->ask($input, $output, $question));
}
parent::interact($input, $output);
}