| author | ymh <ymh.work@gmail.com> |
| Fri, 25 Nov 2011 18:55:42 +0100 | |
| changeset 42 | 0e57c730bb18 |
| parent 25 | 11fd79666374 |
| child 74 | 901463f9b11c |
| permissions | -rwxr-xr-x |
| 25 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* This file is part of the WikiTagBundle package. |
|
5 |
* |
|
6 |
* (c) IRI <http://www.iri.centrepompidou.fr/> |
|
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 IRI\Bundle\WikiTagBundle\Command; |
|
13 |
||
14 |
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
15 |
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
16 |
use Symfony\Component\Console\Input\InputArgument; |
|
17 |
use Symfony\Component\Console\Input\InputOption; |
|
18 |
use Symfony\Component\Console\Input\InputInterface; |
|
19 |
use Symfony\Component\Console\Output\OutputInterface; |
|
20 |
use Symfony\Component\Console\Output\Output; |
|
21 |
use Doctrine\ORM\Tools\SchemaTool; |
|
22 |
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand; |
|
23 |
use Symfony\Bundle\DoctrineBundle\Command\Proxy\DoctrineCommandHelper; |
|
|
42
0e57c730bb18
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
25
diff
changeset
|
24 |
use IRI\Bundle\WikiTagBundle\Utils\FilteredSchemaTool; |
| 25 | 25 |
|
26 |
/** |
|
27 |
* Command to execute the SQL needed to generate the database schema for |
|
28 |
* a given entity manager. |
|
29 |
* |
|
30 |
* This file is a direct adaptation of the Symfony\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand |
|
31 |
* |
|
32 |
*/ |
|
33 |
class CreateSchemaDoctrineCommand extends CreateCommand implements ContainerAwareInterface |
|
34 |
{ |
|
35 |
protected function configure() |
|
36 |
{ |
|
37 |
parent::configure(); |
|
38 |
||
39 |
$this |
|
40 |
->setName('wikitag:schema:create') |
|
41 |
->setDescription('Executes (or dumps) the SQL needed to generate the database schema') |
|
42 |
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command') |
|
43 |
->setHelp(<<<EOT |
|
44 |
The <info>doctrine:schema:create</info> command executes the SQL needed to |
|
45 |
generate the database schema for the default entity manager: |
|
46 |
||
47 |
<info>php app/console doctrine:schema:create</info> |
|
48 |
||
49 |
You can also generate the database schema for a specific entity manager: |
|
50 |
||
51 |
<info>php app/console doctrine:schema:create --em=default</info> |
|
52 |
||
53 |
Finally, instead of executing the SQL, you can output the SQL: |
|
54 |
||
55 |
<info>php app/console doctrine:schema:create --dump-sql</info> |
|
56 |
EOT |
|
57 |
); |
|
58 |
} |
|
59 |
||
60 |
/** |
|
61 |
* @var ContainerInterface |
|
62 |
*/ |
|
63 |
private $container; |
|
64 |
||
65 |
protected function getContainer() |
|
66 |
{ |
|
67 |
if (null === $this->container) { |
|
68 |
$this->container = $this->getApplication()->getKernel()->getContainer(); |
|
69 |
} |
|
70 |
||
71 |
return $this->container; |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* @see ContainerAwareInterface::setContainer() |
|
76 |
*/ |
|
77 |
public function setContainer(ContainerInterface $container = null) |
|
78 |
{ |
|
79 |
$this->container = $container; |
|
80 |
} |
|
81 |
||
82 |
||
83 |
protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas) |
|
84 |
{ |
|
85 |
||
|
42
0e57c730bb18
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
25
diff
changeset
|
86 |
$filteredSchemaTool = new FilteredSchemaTool($this->getHelper("em")->getEntityManager(), $this->getContainer()); |
| 25 | 87 |
|
|
42
0e57c730bb18
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
25
diff
changeset
|
88 |
parent::executeSchemaCommand($input, $output, $filteredSchemaTool, $metadatas); |
|
0e57c730bb18
Documentation and add alternative wp url and label + migrations
ymh <ymh.work@gmail.com>
parents:
25
diff
changeset
|
89 |
|
| 25 | 90 |
} |
91 |
||
92 |
protected function execute(InputInterface $input, OutputInterface $output) |
|
93 |
{ |
|
94 |
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
|
95 |
||
96 |
parent::execute($input, $output); |
|
97 |
} |
|
98 |
} |