本文整理汇总了PHP中Sensio\Bundle\GeneratorBundle\Command\Validators::getReservedWords方法的典型用法代码示例。如果您正苦于以下问题:PHP Validators::getReservedWords方法的具体用法?PHP Validators::getReservedWords怎么用?PHP Validators::getReservedWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sensio\Bundle\GeneratorBundle\Command\Validators
的用法示例。
在下文中一共展示了Validators::getReservedWords方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: interact
/**
* @see Command
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
$questionHelper = $this->getQuestionHelper();
$questionHelper->writeSection($output, 'Welcome to the Sylius resource generator');
// namespace
$output->writeln(array('', 'This command helps you generate Sylius resource.', '', 'First, you need to give the entity name you want to generate.', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
$bundleNames = $this->getContainer()->get('kernel')->getBundles();
$bundleList = array();
foreach ($bundleNames as $bundle) {
if ($bundle instanceof AbstractResourceBundle) {
$bundleList[] = $bundle->getName();
}
}
while (true) {
$question = new Question($questionHelper->getQuestion('The Entity shortcut name', $input->getOption('resource')), $input->getOption('resource'));
$question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'));
$question->setAutocompleterValues($bundleList);
$resource = $questionHelper->ask($input, $output, $question);
$resource = Validators::validateEntityName($resource);
list($bundle, $entity) = $this->parseShortcutNotation($resource);
$bundle = Validators::validateBundleName($bundle);
try {
$this->getContainer()->get('kernel')->getBundle($bundle);
} catch (\Exception $e) {
$output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $bundle));
continue;
}
if (in_array($entity, Validators::getReservedWords())) {
$output->writeln(sprintf('<bg=red> "%s" is a reserved word</>.', $entity));
continue;
}
break;
}
$input->setOption('resource', $resource);
$dialog = $this->getHelper('dialog');
if ($dialog->askConfirmation($output, '<question>Would you add form? (y/N)</question>')) {
$this->commands[] = array('avoo:generate:form', '--entity' => $resource, '--no-summary' => true);
if ($dialog->askConfirmation($output, '<question>Would you add controller? (y/N)</question>')) {
$this->commands[] = array('avoo:generate:controller', '--controller' => $resource, '--no-summary' => true);
if ($dialog->askConfirmation($output, '<question>Would you add CRUD? (y/N)</question>')) {
$backend = $dialog->askConfirmation($output, '<question>With backend? (y/N)</question>');
$crud = array();
if (!$backend) {
$crud['--no-backend'] = true;
} else {
while (true) {
$question = new Question($questionHelper->getQuestion('Backend bundle', null));
$question->setValidator(array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateBundleName'));
$question->setAutocompleterValues($bundleList);
$backendBundle = $questionHelper->ask($input, $output, $question);
try {
$this->getContainer()->get('kernel')->getBundle($backendBundle);
break;
} catch (\Exception $e) {
$output->writeln(sprintf('<bg=red>Bundle "%s" does not exist.</>', $backendBundle));
$input->setOption('no-summary', null);
continue;
}
}
$crud['--backend'] = $backendBundle;
}
$this->commands[] = array_merge(array('avoo:generate:crud', '--entity' => $resource, '--no-summary' => true), $crud);
}
}
$this->commands[] = array('cache:clear', '--no-warmup' => true);
}
}