Move CLI app to use DIC.
This commit is contained in:
parent
3eb1648e13
commit
063bec407d
24
console
24
console
|
@ -12,29 +12,9 @@ define('PHPCI_IS_CONSOLE', true);
|
||||||
|
|
||||||
require('bootstrap.php');
|
require('bootstrap.php');
|
||||||
|
|
||||||
use PHPCI\Command\RunCommand;
|
|
||||||
use PHPCI\Command\RebuildCommand;
|
|
||||||
use PHPCI\Command\GenerateCommand;
|
|
||||||
use PHPCI\Command\UpdateCommand;
|
|
||||||
use PHPCI\Command\InstallCommand;
|
|
||||||
use PHPCI\Command\DaemonCommand;
|
|
||||||
use PHPCI\Command\PollCommand;
|
|
||||||
use PHPCI\Command\CreateAdminCommand;
|
|
||||||
use PHPCI\Command\CreateBuildCommand;
|
|
||||||
use PHPCI\Service\BuildService;
|
|
||||||
use Symfony\Component\Console\Application;
|
use Symfony\Component\Console\Application;
|
||||||
use b8\Store\Factory;
|
|
||||||
|
|
||||||
$application = new Application();
|
/** @var Application */
|
||||||
|
$application = $container->get('console.application');
|
||||||
$application->add(new RunCommand($loggerConfig->getFor('RunCommand')));
|
|
||||||
$application->add(new RebuildCommand($loggerConfig->getFor('RunCommand')));
|
|
||||||
$application->add(new InstallCommand);
|
|
||||||
$application->add(new UpdateCommand($loggerConfig->getFor('UpdateCommand')));
|
|
||||||
$application->add(new GenerateCommand);
|
|
||||||
$application->add(new DaemonCommand($loggerConfig->getFor('DaemonCommand')));
|
|
||||||
$application->add(new PollCommand($loggerConfig->getFor('PollCommand')));
|
|
||||||
$application->add(new CreateAdminCommand(Factory::getStore('User')));
|
|
||||||
$application->add(new CreateBuildCommand(Factory::getStore('Project'), new BuildService(Factory::getStore('Build'))));
|
|
||||||
|
|
||||||
$application->run();
|
$application->run();
|
||||||
|
|
62
services.yml
62
services.yml
|
@ -1,6 +1,8 @@
|
||||||
parameters:
|
parameters:
|
||||||
config_file: ./../PHPCI/config.yml
|
application.name: PHPCI
|
||||||
storage.factory: b8\Store\Factory
|
application.version: 1.7-dev
|
||||||
|
config_file: PHPCI/config.yml
|
||||||
|
storage.factory: b8\Store\Factory
|
||||||
|
|
||||||
services:
|
services:
|
||||||
storage.user:
|
storage.user:
|
||||||
|
@ -35,3 +37,59 @@ services:
|
||||||
application:
|
application:
|
||||||
class: PHPCI\Application
|
class: PHPCI\Application
|
||||||
arguments: [@config, @http.request, @http.response, @storage.user, @storage.project]
|
arguments: [@config, @http.request, @http.response, @storage.user, @storage.project]
|
||||||
|
build:
|
||||||
|
class: PHPCI\Service\BuildService
|
||||||
|
arguments: [@storage.build]
|
||||||
|
|
||||||
|
console.application:
|
||||||
|
class: Symfony\Component\Console\Application
|
||||||
|
arguments:
|
||||||
|
- %application.name%
|
||||||
|
- %application.version%
|
||||||
|
calls:
|
||||||
|
- [add, ['@console.command.run']]
|
||||||
|
- [add, ['@console.command.rebuild']]
|
||||||
|
- [add, ['@console.command.install']]
|
||||||
|
- [add, ['@console.command.update']]
|
||||||
|
- [add, ['@console.command.generate']]
|
||||||
|
- [add, ['@console.command.daemon']]
|
||||||
|
- [add, ['@console.command.poll']]
|
||||||
|
- [add, ['@console.command.create_admin']]
|
||||||
|
- [add, ['@console.command.create_build']]
|
||||||
|
console.logger:
|
||||||
|
class: Monolog\Logger
|
||||||
|
arguments:
|
||||||
|
- cli
|
||||||
|
console.command.run:
|
||||||
|
class: PHPCI\Command\RunCommand
|
||||||
|
arguments:
|
||||||
|
- @console.logger
|
||||||
|
console.command.rebuild:
|
||||||
|
class: PHPCI\Command\RebuildCommand
|
||||||
|
arguments:
|
||||||
|
- @console.logger
|
||||||
|
console.command.update:
|
||||||
|
class: PHPCI\Command\UpdateCommand
|
||||||
|
arguments:
|
||||||
|
- @console.logger
|
||||||
|
console.command.daemon:
|
||||||
|
class: PHPCI\Command\DaemonCommand
|
||||||
|
arguments:
|
||||||
|
- @console.logger
|
||||||
|
console.command.poll:
|
||||||
|
class: PHPCI\Command\PollCommand
|
||||||
|
arguments:
|
||||||
|
- @console.logger
|
||||||
|
console.command.create_admin:
|
||||||
|
class: PHPCI\Command\CreateAdminCommand
|
||||||
|
arguments:
|
||||||
|
- @storage.user
|
||||||
|
console.command.create_build:
|
||||||
|
class: PHPCI\Command\CreateBuildCommand
|
||||||
|
arguments:
|
||||||
|
- @storage.project
|
||||||
|
- @build
|
||||||
|
console.command.install:
|
||||||
|
class: PHPCI\Command\InstallCommand
|
||||||
|
console.command.generate:
|
||||||
|
class: PHPCI\Command\GenerateCommand
|
||||||
|
|
2
vars.php
2
vars.php
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// Define our APPLICATION_PATH, if not already defined:
|
// Define our APPLICATION_PATH, if not already defined:
|
||||||
if (!defined('APPLICATION_PATH')) {
|
if (!defined('APPLICATION_PATH')) {
|
||||||
define('APPLICATION_PATH', dirname(__FILE__) . '/');
|
define('APPLICATION_PATH', __DIR__ . '/');
|
||||||
define('PHPCI_DIR', APPLICATION_PATH);
|
define('PHPCI_DIR', APPLICATION_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue