-
Notifications
You must be signed in to change notification settings - Fork 452
/
Application.php
88 lines (78 loc) · 3.43 KB
/
Application.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Concrete\Core\Console;
use Concrete\Core\Application\Application as CMSApplication;
use Concrete\Core\Updater\Migrations\Configuration as MigrationsConfiguration;
use Doctrine\DBAL\Migrations\OutputWriter;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Output\ConsoleOutput;
class Application extends SymfonyApplication
{
/**
* @var CMSApplication
*/
protected $app;
public function __construct(CMSApplication $app)
{
$this->app = $app;
parent::__construct('concrete5', $this->app->make('config')->get('concrete.version'));
}
public function setupDefaultCommands()
{
$this->add(new Command\IsInstalledCommand());
$this->add(new Command\InfoCommand());
$this->add(new Command\InstallCommand());
$this->add(new Command\InstallLanguageCommand());
$this->add(new Command\TranslatePackageCommand());
$this->add(new Command\GenerateIDESymbolsCommand());
$this->add(new Command\ConfigCommand());
$this->add(new Command\PackPackageCommand());
$this->add(new Command\ExecCommand());
$this->add(new Command\ServiceCommand());
if ($this->app->isInstalled()) {
$this->add(new Command\CompareSchemaCommand());
$this->add(new Command\ClearCacheCommand());
$this->add(new Command\InstallPackageCommand());
$this->add(new Command\UninstallPackageCommand());
$this->add(new Command\UpdatePackageCommand());
$this->add(new Command\BlacklistClear());
$this->add(new Command\FillThumbnailsTableCommand());
}
$this->setupRestrictedCommands();
$this->setupDoctrineCommands();
}
public function setupRestrictedCommands()
{
$this->add(new Command\ResetCommand());
if ($this->app->isInstalled()) {
$this->add(new Command\JobCommand());
$this->add(new Command\UpdateCommand());
}
}
public function setupDoctrineCommands()
{
if ($this->app->isInstalled()) {
$helperSet = ConsoleRunner::createHelperSet(\ORM::entityManager());
$this->setHelperSet($helperSet);
$migrationsConfiguration = new MigrationsConfiguration();
$output = new ConsoleOutput();
$migrationsConfiguration->setOutputWriter(new OutputWriter(function ($message) use ($output) {
$output->writeln($message);
}));
/** @var \Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand[] $commands */
$commands = [
new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(),
new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand(),
];
foreach ($commands as $migrationsCommand) {
$migrationsCommand->setMigrationConfiguration($migrationsConfiguration);
$this->add($migrationsCommand);
}
ConsoleRunner::addCommands($this);
}
}
}