当前位置: 首页>>代码示例>>PHP>>正文


PHP Validators::getReservedWords方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:avoo,项目名称:FrameworkGeneratorBundle,代码行数:72,代码来源:CreateResourceCommand.php


注:本文中的Sensio\Bundle\GeneratorBundle\Command\Validators::getReservedWords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。