vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/CreateSchemaDoctrineCommand.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\DoctrineBundle\Command\Proxy;
       
    13 
       
    14 use Symfony\Component\Console\Input\InputArgument;
       
    15 use Symfony\Component\Console\Input\InputOption;
       
    16 use Symfony\Component\Console\Input\InputInterface;
       
    17 use Symfony\Component\Console\Output\OutputInterface;
       
    18 use Symfony\Component\Console\Output\Output;
       
    19 use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
       
    20 
       
    21 /**
       
    22  * Command to execute the SQL needed to generate the database schema for
       
    23  * a given entity manager.
       
    24  *
       
    25  * @author Fabien Potencier <fabien@symfony.com>
       
    26  * @author Jonathan H. Wage <jonwage@gmail.com>
       
    27  */
       
    28 class CreateSchemaDoctrineCommand extends CreateCommand
       
    29 {
       
    30     protected function configure()
       
    31     {
       
    32         parent::configure();
       
    33 
       
    34         $this
       
    35             ->setName('doctrine:schema:create')
       
    36             ->setDescription('Executes (or dumps) the SQL needed to generate the database schema')
       
    37             ->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command')
       
    38             ->setHelp(<<<EOT
       
    39 The <info>doctrine:schema:create</info> command executes the SQL needed to
       
    40 generate the database schema for the default entity manager:
       
    41 
       
    42 <info>php app/console doctrine:schema:create</info>
       
    43 
       
    44 You can also generate the database schema for a specific entity manager:
       
    45 
       
    46 <info>php app/console doctrine:schema:create --em=default</info>
       
    47 
       
    48 Finally, instead of executing the SQL, you can output the SQL:
       
    49 
       
    50 <info>php app/console doctrine:schema:create --dump-sql</info>
       
    51 EOT
       
    52         );
       
    53     }
       
    54 
       
    55     protected function execute(InputInterface $input, OutputInterface $output)
       
    56     {
       
    57         DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em'));
       
    58 
       
    59         parent::execute($input, $output);
       
    60     }
       
    61 }