當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Validators::validateEntityName方法代碼示例

本文整理匯總了PHP中Sensio\Bundle\GeneratorBundle\Command\Validators::validateEntityName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validators::validateEntityName方法的具體用法?PHP Validators::validateEntityName怎麽用?PHP Validators::validateEntityName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sensio\Bundle\GeneratorBundle\Command\Validators的用法示例。


在下文中一共展示了Validators::validateEntityName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $confirmationQuestion = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $confirmationQuestion)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     GeneratorUtils::ensureOptionsProvided($input, array('entity', 'fields', 'prefix'));
     $entityInput = Validators::validateEntityName($input->getOption('entity'));
     list($bundleName, $entity) = $this->parseShortcutNotation($entityInput);
     $format = 'annotation';
     $fields = $this->parseFields($input->getOption('fields'));
     $prefix = $input->getOption('prefix');
     $questionHelper->writeSection($output, 'Entity generation');
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundleName);
     $generator = $this->getGenerator($this->getApplication()->getKernel()->getBundle("KunstmaanGeneratorBundle"));
     $generator->generate($bundle, $entity, $format, array_values($fields), $input->getOption('with-repository'), $prefix);
     $output->writeln('Generating the entity code: <info>OK</info>');
     $withAdminlist = $input->getOption('with-adminlist');
     if ($withAdminlist) {
         $command = $this->getApplication()->find('kuma:generate:adminlist');
         $arguments = array('command' => 'doctrine:fixtures:load', '--entity' => $entityInput);
         $input = new ArrayInput($arguments);
         $command->run($input, $output);
     }
     $questionHelper->writeGeneratorSummary($output, array());
     $output->writeln(array('Make sure you update your database first before you test the entity/adminlist:', '    Directly update your database:          <comment>app/console doctrine:schema:update --force</comment>', '    Create a Doctrine migration and run it: <comment>app/console doctrine:migrations:diff && app/console doctrine:migrations:migrate</comment>', ''));
 }
開發者ID:hyrmedia,項目名稱:KunstmaanBundlesCMS,代碼行數:34,代碼來源:GenerateEntityCommand.php

示例2: execute

 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     if ($input->isInteractive()) {
         if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     $translationEntity = Validators::validateEntityName(sprintf('%sTranslation', $input->getOption('entity')));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     list($translationBundle, $translationEntity) = $this->parseShortcutNotation($translationEntity);
     $format = Validators::validateFormat($input->getOption('format'));
     $fields = $this->parseFields($input->getOption('fields'));
     $translatableFields = $this->parseFields($input->getOption('translatable-fields'));
     $dialog->writeSection($output, 'Entities generation');
     $kernel = $this->getContainer()->get('kernel');
     $bundle = $kernel->getBundle($bundle);
     $translationBundle = $kernel->getBundle($translationBundle);
     /** @var OrkestroEntityGenerator $generator */
     $generator = $this->getGenerator();
     $generator->generateTranslatable($bundle, $entity, $translationEntity, $format, array_values($fields), array_values($translatableFields), $input->getOption('with-repository'));
     $output->writeln('Generating the entities code: <info>OK</info>');
     $dialog->writeGeneratorSummary($output, array());
 }
開發者ID:orkestro,項目名稱:orkestro,代碼行數:29,代碼來源:GenerateOrkestroEntityCommand.php

示例3: execute

 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     $fields = $this->parseFields($input->getOption('fields'));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeSection($output, 'Entity generation');
     }
     /** @var TemplateInterface $generator */
     $generator = $this->getGenerator();
     $generator->setConfiguration('fields', $fields);
     if ($input->getOption('no-interface')) {
         $generator->setConfiguration('with_interface', false);
     }
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     $runner($generator->generate($entity));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeGeneratorSummary($output, $generator->getErrors());
     }
 }
開發者ID:avoo,項目名稱:FrameworkGeneratorBundle,代碼行數:31,代碼來源:CreateModelCommand.php

示例4: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     if ($input->isInteractive()) {
         if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = Validators::validateFormat($input->getOption('format'));
     $prefix = $this->getRoutePrefix($input, $entity);
     $withWrite = $input->getOption('with-write');
     $dialog->writeSection($output, 'CRUD generation');
     $entityClass = $this->getContainer()->get('doctrine')->getEntityNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $generator = $this->getGenerator();
     $generator->generate($bundle, $entity, $metadata[0], $format, $prefix, $withWrite);
     $output->writeln('Generating the CRUD code: <info>OK</info>');
     $errors = array();
     $runner = $dialog->getRunner($output, $errors);
     // form
     if ($withWrite) {
         $this->generateForm($bundle, $entity, $metadata);
         $output->writeln('Generating the Form code: <info>OK</info>');
     }
     // routing
     if ('annotation' != $format) {
         $runner($this->updateRouting($dialog, $input, $output, $bundle, $format, $entity, $prefix));
     }
     $dialog->writeGeneratorSummary($output, $errors);
 }
開發者ID:r0ma,項目名稱:SensioGeneratorBundle,代碼行數:37,代碼來源:GenerateDoctrineCrudCommand.php

示例5: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     // Start question helper
     $questionHelper = $this->getQuestionHelper();
     $questionHelper->writeSection($output, 'Welcome to the united CRUD generator!');
     // get entity
     $entity = $input->getOption('entity');
     $question = new Question($questionHelper->getQuestion('Entity', $entity), $entity);
     $question->setValidator(function ($answer) {
         return Validators::validateEntityName($answer);
     });
     $complete = new EntitiesAutoCompleter($this->getContainer()->get('doctrine')->getManager());
     $completeEntities = $complete->getSuggestions();
     $question->setAutocompleterValues($completeEntities);
     $entity = $questionHelper->ask($input, $output, $question);
     $input->setOption('entity', $entity);
     // get bundle
     $destinationBundle = $input->getOption('bundle');
     $question = new Question($questionHelper->getQuestion('Destination bundle', $destinationBundle), $destinationBundle);
     $question->setValidator(function ($answer) {
         return Validators::validateBundleName($answer);
     });
     $question->setAutocompleterValues($this->getBundleSuggestions());
     $destinationBundle = $questionHelper->ask($input, $output, $question);
     $input->setOption('bundle', $destinationBundle);
 }
開發者ID:franzwilding,項目名稱:UnitedBundle,代碼行數:29,代碼來源:UnitedGenerateCrudCommand.php

示例6: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $prefix = $this->getRoutePrefix($input, $entity);
     $forceOverwrite = $input->getOption('overwrite');
     $questionHelper->writeSection($output, 'REST api generation');
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $resource = $input->getOption('resource');
     $document = $input->getOption('document');
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $prefix, $forceOverwrite, $resource, $document);
     $output->writeln('Generating the REST api code: <info>OK</info>');
     $errors = array();
     // form
     $this->generateForm($bundle, $entity, $metadata);
     $output->writeln('Generating the Form code: <info>OK</info>');
     $questionHelper->writeGeneratorSummary($output, $errors);
 }
開發者ID:dark-bm,項目名稱:mdtgeneratorbundle,代碼行數:32,代碼來源:GenerateDoctrineRESTCommand.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $field = $input->getOption('field');
     print $bundle . ":" . $entity . "->" . $field;
     $repo = $this->getContainer()->get('doctrine')->getRepository($bundle . ":" . $entity);
     $em = $this->getContainer()->get('doctrine')->getManager();
     $ids = $em->createQuery("SELECT e.id FROM " . $bundle . ":" . $entity . " e ORDER BY e.id ASC")->setMaxResults(16000)->getArrayResult();
     foreach ($ids as $pos => $e) {
         $toFlush = false;
         $entity = $repo->findOneById($e['id']);
         $fileData = $entity->{'get' . ucfirst($field)}();
         if (!$fileData) {
             continue;
         }
         $filename = $fileData['dir'] . '/' . $fileData['fileName'];
         if (file_exists($filename)) {
             //print "\n exists " . $filename;
             $byFileNameExists = true;
         } else {
             //print "\n NO exists " . $filename;
             $byFileNameExists = false;
         }
         $webDir = $this->getContainer()->getParameter('iphp.web_dir');
         $filenameByPath = $webDir . $fileData['path'];
         if (file_exists($filenameByPath)) {
             //  print "\n By Path exists " . $filenameByPath;
             $byFilePathExists = true;
         } else {
             //  print "\n By Path NO exists " . $filenameByPath;
             $byFilePathExists = false;
         }
         print "\n\n " . $entity->getId() . ' ' . (string) $entity;
         if ($byFilePathExists && $byFileNameExists) {
             print ": NO PROBLEM";
             continue;
         }
         if (!$byFilePathExists && $byFileNameExists) {
             print "\nresave " . $filename;
             print file_exists($filename) ? " EXISTS" : " NO EXISTS";
             $fileObj = new \Symfony\Component\HttpFoundation\File\File($filename);
             print "\n Obj created";
             $entity->{'set' . ucfirst($field)}($fileObj);
             $em->persist($entity);
             $toFlush = true;
             print 'saved';
         }
         if ($pos % 20 == 0 && $toFlush) {
             $em->flush();
         }
         if ($pos % 100 == 0) {
             $em->clear();
         }
     }
 }
開發者ID:khasinski,項目名稱:Iphp,代碼行數:57,代碼來源:RepairFileDataCommand.php

示例8: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $entity = Validators::validateEntityName($input->getArgument('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getApplication()->getKernel()->getBundle($bundle);
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0]);
     $output->writeln(sprintf('The new %s.php class file has been created under %s.', $generator->getClassName(), $generator->getClassPath()));
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:14,代碼來源:GenerateDoctrineFormCommand.php

示例9: execute

 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     Validators::validateEntityName($input->getOption('entity'));
     $dialog = $this->getDialogHelper();
     if ($input->getOption('trait')) {
         if (PHP_MAJOR_VERSION < 5 || PHP_MINOR_VERSION < 4) {
             throw new \RuntimeException('You need PHP > 5.4 to use trait feature');
         }
     }
     if (null === $input->getOption('controller')) {
         throw new \RuntimeException('The controller option must be provided.');
     }
     list($bundle, $controller) = $this->parseShortcutNotation($input->getOption('controller'));
     /** @var Bundle $bundle */
     if (is_string($bundle)) {
         $bundle = Validators::validateBundleName($bundle);
         try {
             $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
         } catch (\Exception $e) {
             $output->writeln(sprintf('<bg=red>Bundle "%s" does not exists.</>', $bundle));
         }
     }
     $dialog->writeSection($output, 'Controller generation: ' . $controller . 'Controller (' . $bundle->getName() . ')');
     /** @var RestControllerGenerator $generator */
     $generator = $this->getGenerator($bundle);
     if ($input->getOption('trait')) {
         $output->writeln("<info>Generating Controller with Traits</info>");
         $generator->setUseTrait(true);
         $generator->generate($bundle, $controller, '', '');
         $output->writeln("<info>Trait Controller Generated</info>");
         $generator->setUseTrait(false);
         $generator->setTemplateFile('UseTraitController.php');
         try {
             $generator->generate($bundle, $controller, '', '');
             $output->writeln("<info>Controller Generated</info>");
         } catch (\RuntimeException $e) {
             $output->writeln("<info>Controller Skipped</info>");
         }
     } else {
         $generator->generate($bundle, $controller, '', '');
         $output->writeln("<info>Controller Generated</info>");
     }
     $output->writeln('Generating the bundle code: <info>OK</info>');
     $dialog->writeGeneratorSummary($output, array());
 }
開發者ID:asiragusa,項目名稱:extjs-bundle,代碼行數:47,代碼來源:GenerateRestControllerCommand.php

示例10: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $entity = Validators::validateEntityName($input->getOption('entity'));
     /** @var TemplateInterface $generator */
     $generator = $this->getGenerator();
     if ($input->getOption('path')) {
         $generator->setConfiguration('path', $input->getOption('path'));
     }
     $questionHelper->writeSection($output, 'Form generation');
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     $runner($generator->generate($entity));
     if (!$input->getOption('no-summary')) {
         $questionHelper->writeGeneratorSummary($output, $generator->getErrors());
     }
 }
開發者ID:avoo,項目名稱:FrameworkGeneratorBundle,代碼行數:20,代碼來源:CreateFormCommand.php

示例11: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = "rest";
     $prefix = $this->getRoutePrefix($input, $entity);
     $forceOverwrite = $input->getOption('overwrite');
     $questionHelper->writeSection($output, 'REST api generation');
     $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
     $metadata = $this->getEntityMetadata($entityClass);
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $resource = $input->getOption('resource');
     $document = $input->getOption('document');
     $form = $input->getOption('form');
     if ($form) {
         $entityName = $input->getOption('entity');
         $process = new Process("app/console doctrine:generate:form {$entityName}");
         $process->run(function ($type, $buffer) {
             if ('err' === $type) {
                 echo 'ERR > ' . $buffer;
             } else {
                 echo 'OUT > ' . $buffer;
             }
         });
     }
     /** @var DoctrineRESTGenerator $generator */
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $prefix, $forceOverwrite, $resource, $document);
     $output->writeln('Generating the REST api code: <info>OK</info>');
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     // form
     $this->generateForm($bundle, $entity, $metadata);
     $output->writeln('Generating the Form code: <info>OK</info>');
     // create route
     $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format, $entity, $prefix));
     $questionHelper->writeGeneratorSummary($output, $errors);
 }
開發者ID:sidux,項目名稱:restgeneratorbundle,代碼行數:49,代碼來源:GenerateDoctrineRESTCommand.php

示例12: interact

 /**
  * Interacts with the user.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getDialogHelper();
     $dialog->writeSection($output, 'Welcome to the Kunstmaan admin list generator');
     // entity
     $entity = null;
     try {
         $entity = $input->getOption('entity') ? Validators::validateEntityName($input->getOption('entity')) : null;
     } catch (\Exception $error) {
         $output->writeln($dialog->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error'));
     }
     if (is_null($entity)) {
         $output->writeln(array('', 'This command helps you to generate an admin list for your entity.', '', 'You must use the shortcut notation like <comment>AcmeBlogBundle:Post</comment>.', ''));
         $entity = $dialog->askAndValidate($output, $dialog->getQuestion('The entity shortcut name', $entity), array('Sensio\\Bundle\\GeneratorBundle\\Command\\Validators', 'validateEntityName'), false, $entity);
         $input->setOption('entity', $entity);
     }
 }
開發者ID:tentwofour,項目名稱:KunstmaanGeneratorBundle,代碼行數:23,代碼來源:GenerateAdminListCommand.php

示例13: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = Validators::validateFormat($input->getOption('format'));
     $prefix = $this->getRoutePrefix($input, $entity);
     $withWrite = $input->getOption('with-write');
     $forceOverwrite = $input->getOption('overwrite');
     $questionHelper->writeSection($output, 'CRUD generation');
     try {
         $entityClass = $this->getContainer()->get('doctrine')->getAliasNamespace($bundle) . '\\' . $entity;
         $metadata = $this->getEntityMetadata($entityClass);
     } catch (\Exception $e) {
         throw new \RuntimeException(sprintf('Entity "%s" does not exist in the "%s" bundle. Create it with the "doctrine:generate:entity" command and then execute this command again.', $entity, $bundle));
     }
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $generator = $this->getGenerator($bundle);
     $generator->generate($bundle, $entity, $metadata[0], $format, $prefix, $withWrite, $forceOverwrite);
     $output->writeln('Generating the CRUD code: <info>OK</info>');
     $errors = array();
     $runner = $questionHelper->getRunner($output, $errors);
     // form
     if ($withWrite) {
         $output->write('Generating the Form code: ');
         if ($this->generateForm($bundle, $entity, $metadata)) {
             $output->writeln('<info>OK</info>');
         } else {
             $output->writeln('<comment>Already exists, skipping</comment>');
         }
     }
     // routing
     if ('annotation' != $format) {
         $runner($this->updateRouting($questionHelper, $input, $output, $bundle, $format, $entity, $prefix));
     }
     $questionHelper->writeGeneratorSummary($output, $errors);
 }
開發者ID:OskarStark,項目名稱:SensioGeneratorBundle,代碼行數:47,代碼來源:GenerateDoctrineCrudCommand.php

示例14: execute

 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = Validators::validateFormat($input->getOption('format'));
     $fields = $this->parseFields($input->getOption('fields'));
     $questionHelper->writeSection($output, 'Entity generation');
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     /** @var DoctrineEntityGenerator $generator */
     $generator = $this->getGenerator();
     $generatorResult = $generator->generate($bundle, $entity, $format, array_values($fields));
     $output->writeln(sprintf('> Generating entity class <info>%s</info>: <comment>OK!</comment>', $this->makePathRelative($generatorResult->getEntityPath())));
     $output->writeln(sprintf('> Generating repository class <info>%s</info>: <comment>OK!</comment>', $this->makePathRelative($generatorResult->getRepositoryPath())));
     if ($generatorResult->getMappingPath()) {
         $output->writeln(sprintf('> Generating mapping file <info>%s</info>: <comment>OK!</comment>', $this->makePathRelative($generatorResult->getMappingPath())));
     }
     $questionHelper->writeGeneratorSummary($output, array());
 }
開發者ID:OskarStark,項目名稱:SensioGeneratorBundle,代碼行數:22,代碼來源:GenerateDoctrineEntityCommand.php

示例15: execute

 /**
  * @throws \InvalidArgumentException When the bundle doesn't end with Bundle (Example: "Bundle/MySampleBundle")
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $questionHelper = $this->getQuestionHelper();
     if ($input->isInteractive()) {
         $question = new ConfirmationQuestion($questionHelper->getQuestion('Do you confirm generation', 'yes', '?'), true);
         if (!$questionHelper->ask($input, $output, $question)) {
             $output->writeln('<error>Command aborted</error>');
             return 1;
         }
     }
     $entity = Validators::validateEntityName($input->getOption('entity'));
     list($bundle, $entity) = $this->parseShortcutNotation($entity);
     $format = Validators::validateFormat($input->getOption('format'));
     $fields = $this->parseFields($input->getOption('fields'));
     $questionHelper->writeSection($output, 'Entity generation');
     $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
     $generator = $this->getGenerator();
     $generator->generate($bundle, $entity, $format, array_values($fields), $input->getOption('with-repository'));
     $output->writeln('Generating the entity code: <info>OK</info>');
     $questionHelper->writeGeneratorSummary($output, array());
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:24,代碼來源:GenerateDoctrineEntityCommand.php


注:本文中的Sensio\Bundle\GeneratorBundle\Command\Validators::validateEntityName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。