|
0
|
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\FrameworkBundle\Command; |
|
|
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 Symfony\Component\Console\Command\Command; |
|
|
20 |
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
|
21 |
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
|
|
22 |
|
|
|
23 |
/** |
|
|
24 |
* Command. |
|
|
25 |
* |
|
|
26 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
27 |
*/ |
|
|
28 |
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface |
|
|
29 |
{ |
|
|
30 |
/** |
|
|
31 |
* @var ContainerInterface |
|
|
32 |
*/ |
|
|
33 |
private $container; |
|
|
34 |
|
|
|
35 |
protected function getContainer() |
|
|
36 |
{ |
|
|
37 |
if (null === $this->container) { |
|
|
38 |
$this->container = $this->getApplication()->getKernel()->getContainer(); |
|
|
39 |
} |
|
|
40 |
|
|
|
41 |
return $this->container; |
|
|
42 |
} |
|
|
43 |
|
|
|
44 |
/** |
|
|
45 |
* @see ContainerAwareInterface::setContainer() |
|
|
46 |
*/ |
|
|
47 |
public function setContainer(ContainerInterface $container = null) |
|
|
48 |
{ |
|
|
49 |
$this->container = $container; |
|
|
50 |
} |
|
|
51 |
} |