Completed
Pull Request — master (#247)
by Tomáš
02:52
created

SchemaCreateCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Kdyby (http://www.kdyby.org)
5
 *
6
 * Copyright (c) 2008 Filip Procházka ([email protected])
7
 *
8
 * For the full copyright and license information, please view the file license.txt that was distributed with this source code.
9
 */
10
11
namespace Kdyby\Doctrine\Console;
12
13
use Doctrine;
14
use Doctrine\ORM\Tools\SchemaTool;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Input\InputOption;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
20
21
/**
22
 * @author Filip Procházka <[email protected]>
23
 */
24
class SchemaCreateCommand extends Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand
25
{
26
27
	/**
28
	 * @var \Kdyby\Doctrine\Tools\CacheCleaner
29
	 * @inject
30
	 */
31
	public $cacheCleaner;
32
33
34
35
	public function __construct()
36
	{
37
		parent::__construct();
38
	}
39
40
41
42
	/**
43
	 * {@inheritDoc}
44
	 */
45
	protected function configure()
46
	{
47
		parent::configure();
48
		$this->addOption('em', NULL, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command');
49
	}
50
51
52
53
	/**
54
	 * {@inheritdoc}
55
	 */
56
	protected function initialize(InputInterface $input, OutputInterface $output)
57
	{
58
		parent::initialize($input, $output);
59
60
		if ($input->getOption('em')) {
61
			CommandHelper::setApplicationEntityManager($this->getHelper('container'), $input->getOption('em'));
62
		}
63
64
		$this->cacheCleaner->invalidate();
65
	}
66
67
68
69
	/**
70
	 * {@inheritdoc}
71
	 */
72
	protected function executeSchemaCommand(InputInterface $input, OutputInterface $output, SchemaTool $schemaTool, array $metadatas)
73
	{
74
		return parent::executeSchemaCommand($input, new ColoredSqlOutput($output), $schemaTool, $metadatas);
75
	}
76
77
}
78