|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* File containing the Application class. |
|
5
|
|
|
* |
|
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
|
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
namespace eZ\Bundle\EzPublishCoreBundle\Console; |
|
10
|
|
|
|
|
11
|
|
|
use eZ\Publish\Core\MVC\Symfony\Event\ConsoleInitEvent; |
|
12
|
|
|
use eZ\Publish\Core\MVC\Symfony\MVCEvents; |
|
13
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application as BaseApplication; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
17
|
|
|
use Symfony\Component\HttpKernel\KernelInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* eZ Publish console application. |
|
21
|
|
|
* Adds options specific to an eZ Publish environment, such as the siteaccess to use. |
|
22
|
|
|
*/ |
|
23
|
|
|
class Application extends BaseApplication |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @see doRun |
|
27
|
|
|
* |
|
28
|
|
|
* @var \Symfony\Component\HttpKernel\KernelInterface |
|
29
|
|
|
*/ |
|
30
|
|
|
private $kernel; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
public function __construct(KernelInterface $kernel) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->kernel = $kernel; |
|
35
|
|
|
parent::__construct($kernel); |
|
36
|
|
|
$this->getDefinition()->addOption( |
|
37
|
|
|
new InputOption('--siteaccess', null, InputOption::VALUE_OPTIONAL, 'SiteAccess to use for operations. If not provided, default siteaccess will be used') |
|
38
|
|
|
); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function doRun(InputInterface $input, OutputInterface $output) |
|
42
|
|
|
{ |
|
43
|
|
|
// boot() will be re-executed by parent, but kernel only boots once regardlessly |
|
44
|
|
|
$this->kernel->boot(); |
|
45
|
|
|
|
|
46
|
|
|
// @todo Contribute a console.init event to Symfony4 in order to rather use that in v3 to drop doRun() overload |
|
47
|
|
|
$this->kernel->getContainer()->get('event_dispatcher')->dispatch( |
|
48
|
|
|
MVCEvents::CONSOLE_INIT, |
|
49
|
|
|
new ConsoleInitEvent($input, $output) |
|
50
|
|
|
); |
|
51
|
|
|
|
|
52
|
|
|
return parent::doRun($input, $output); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|