Swtich DIC to symfony container.
This commit is contained in:
parent
a0e72b9bc7
commit
3eb1648e13
|
@ -26,10 +26,9 @@ if (empty($timezone)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
use PHPCI\Logging\LoggerConfig;
|
use PHPCI\Logging\LoggerConfig;
|
||||||
use Pimple\Container;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use G\Yaml2Pimple\ContainerBuilder;
|
|
||||||
use G\Yaml2Pimple\YamlFileLoader;
|
|
||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocator;
|
||||||
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||||
|
|
||||||
$configFile = __DIR__ . '/PHPCI/config.yml';
|
$configFile = __DIR__ . '/PHPCI/config.yml';
|
||||||
$configEnv = getenv('phpci_config_file');
|
$configEnv = getenv('phpci_config_file');
|
||||||
|
@ -52,32 +51,14 @@ if (defined('PHPCI_IS_CONSOLE') && PHPCI_IS_CONSOLE) {
|
||||||
$loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php");
|
$loggerConfig = LoggerConfig::newFromFile(__DIR__ . "/loggerconfig.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
$container = new Container();
|
$container = new ContainerBuilder();
|
||||||
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__));
|
||||||
$builder = new ContainerBuilder($container);
|
|
||||||
$loader = new YamlFileLoader($builder, new FileLocator(__DIR__));
|
|
||||||
$loader->load('services.yml');
|
$loader->load('services.yml');
|
||||||
|
|
||||||
if (file_exists($configFile)) {
|
if (file_exists($configFile)) {
|
||||||
$container['config_file'] = $configFile;
|
$container->set('config_file', $configFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
$container['store.user'] = function () {
|
|
||||||
return b8\Store\Factory::getStore('User');
|
|
||||||
};
|
|
||||||
|
|
||||||
$container['store.project'] = function () {
|
|
||||||
return b8\Store\Factory::getStore('Project');
|
|
||||||
};
|
|
||||||
|
|
||||||
$container['store.build'] = function () {
|
|
||||||
return b8\Store\Factory::getStore('Build');
|
|
||||||
};
|
|
||||||
|
|
||||||
$container['store.build_meta'] = function () {
|
|
||||||
return b8\Store\Factory::getStore('BuildMeta');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow to modify PHPCI configuration without modify versioned code.
|
* Allow to modify PHPCI configuration without modify versioned code.
|
||||||
* Dameons should be killed to apply changes in the file.
|
* Dameons should be killed to apply changes in the file.
|
||||||
|
@ -91,4 +72,4 @@ if (is_readable($localVarsFile)) {
|
||||||
|
|
||||||
require_once(__DIR__ . '/vars.php');
|
require_once(__DIR__ . '/vars.php');
|
||||||
|
|
||||||
\PHPCI\Helper\Lang::init($container['config']);
|
\PHPCI\Helper\Lang::init($container->get('config'));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name" : "block8/phpci",
|
"name" : "block8/phpci",
|
||||||
"description" : "Simple continuous integration for PHP projects.",
|
"description" : "Simple continuous integration for PHP projects.",
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "stable",
|
||||||
"type" : "library",
|
"type" : "library",
|
||||||
"keywords" : ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"],
|
"keywords" : ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"],
|
||||||
"homepage" : "http://www.phptesting.org/",
|
"homepage" : "http://www.phptesting.org/",
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
"robmorgan/phinx": "~0.4",
|
"robmorgan/phinx": "~0.4",
|
||||||
"sensiolabs/ansi-to-html": "~1.1",
|
"sensiolabs/ansi-to-html": "~1.1",
|
||||||
"jakub-onderka/php-parallel-lint": "0.8.*",
|
"jakub-onderka/php-parallel-lint": "0.8.*",
|
||||||
"gonzalo123/yaml2pimple": "^1.0@dev"
|
"symfony/dependency-injection": "~2.7"
|
||||||
},
|
},
|
||||||
|
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
|
|
176
composer.lock
generated
176
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "bd1ad78288fdaea0e4a92b25d644b204",
|
"hash": "4c1675c48cc8ac6ab60ff9a6663bcdb8",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "block8/b8framework",
|
"name": "block8/b8framework",
|
||||||
|
@ -53,54 +53,6 @@
|
||||||
],
|
],
|
||||||
"time": "2014-12-01 21:02:58"
|
"time": "2014-12-01 21:02:58"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "gonzalo123/yaml2pimple",
|
|
||||||
"version": "dev-master",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/gonzalo123/yml2pimple.git",
|
|
||||||
"reference": "63145b8c1506cc4a01e4b79b2c5b7222f5ab9d94"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/gonzalo123/yml2pimple/zipball/63145b8c1506cc4a01e4b79b2c5b7222f5ab9d94",
|
|
||||||
"reference": "63145b8c1506cc4a01e4b79b2c5b7222f5ab9d94",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"pimple/pimple": "3.0.*@dev",
|
|
||||||
"symfony/config": "2.6.*@dev",
|
|
||||||
"symfony/yaml": "2.6.*@dev"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.0-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"G\\Yaml2Pimple\\": "src/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Gonzalo Ayuso",
|
|
||||||
"email": "gonzalo123@gmail.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Build a Pimple/Container from a config file",
|
|
||||||
"keywords": [
|
|
||||||
"container",
|
|
||||||
"dependency injection",
|
|
||||||
"pimple"
|
|
||||||
],
|
|
||||||
"time": "2014-10-04 14:56:45"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "ircmaxell/password-compat",
|
"name": "ircmaxell/password-compat",
|
||||||
"version": "v1.0.4",
|
"version": "v1.0.4",
|
||||||
|
@ -609,6 +561,66 @@
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2015-01-25 04:39:26"
|
"time": "2015-01-25 04:39:26"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/dependency-injection",
|
||||||
|
"version": "v2.7.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/DependencyInjection.git",
|
||||||
|
"reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
|
||||||
|
"reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.9"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"symfony/expression-language": "<2.6"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/config": "~2.2",
|
||||||
|
"symfony/expression-language": "~2.6",
|
||||||
|
"symfony/phpunit-bridge": "~2.7",
|
||||||
|
"symfony/yaml": "~2.1"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/config": "",
|
||||||
|
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
||||||
|
"symfony/yaml": ""
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.7-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\DependencyInjection\\": ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Symfony DependencyInjection Component",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"time": "2015-05-29 14:44:44"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/filesystem",
|
"name": "symfony/filesystem",
|
||||||
"version": "v2.6.4",
|
"version": "v2.6.4",
|
||||||
|
@ -1971,66 +1983,6 @@
|
||||||
],
|
],
|
||||||
"time": "2015-03-04 02:07:03"
|
"time": "2015-03-04 02:07:03"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "symfony/dependency-injection",
|
|
||||||
"version": "v2.6.4",
|
|
||||||
"target-dir": "Symfony/Component/DependencyInjection",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/symfony/DependencyInjection.git",
|
|
||||||
"reference": "42bbb43fab66292a1865dc9616c299904c3d4d14"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/42bbb43fab66292a1865dc9616c299904c3d4d14",
|
|
||||||
"reference": "42bbb43fab66292a1865dc9616c299904c3d4d14",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.3"
|
|
||||||
},
|
|
||||||
"conflict": {
|
|
||||||
"symfony/expression-language": "<2.6"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"symfony/config": "~2.2",
|
|
||||||
"symfony/expression-language": "~2.6",
|
|
||||||
"symfony/yaml": "~2.1"
|
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"symfony/config": "",
|
|
||||||
"symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
|
|
||||||
"symfony/yaml": ""
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "2.6-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"Symfony\\Component\\DependencyInjection\\": ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "http://symfony.com/contributors"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Symfony DependencyInjection Component",
|
|
||||||
"homepage": "http://symfony.com",
|
|
||||||
"time": "2015-01-25 04:39:26"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
"version": "v2.6.4",
|
"version": "v2.6.4",
|
||||||
|
@ -2120,10 +2072,8 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": {
|
"stability-flags": [],
|
||||||
"gonzalo123/yaml2pimple": 20
|
|
||||||
},
|
|
||||||
"prefer-stable": false,
|
"prefer-stable": false,
|
||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": {
|
"platform": {
|
||||||
|
|
|
@ -12,6 +12,6 @@ session_start();
|
||||||
|
|
||||||
require_once(__DIR__ . '/../bootstrap.php');
|
require_once(__DIR__ . '/../bootstrap.php');
|
||||||
|
|
||||||
$app = $container['application'];
|
$app = $container->get('application');
|
||||||
|
|
||||||
print $app->handleRequest();
|
print $app->handleRequest();
|
||||||
|
|
47
services.yml
47
services.yml
|
@ -1,16 +1,37 @@
|
||||||
parameters:
|
parameters:
|
||||||
config_file: ./PHPCI/config.yml
|
config_file: ./../PHPCI/config.yml
|
||||||
|
storage.factory: b8\Store\Factory
|
||||||
|
|
||||||
services:
|
services:
|
||||||
http.request:
|
storage.user:
|
||||||
class: b8\Http\Request
|
class: PHPCI\Store\Base\UserStore
|
||||||
arguments: []
|
factory: [%storage.factory%, getStore]
|
||||||
http.response:
|
arguments:
|
||||||
class: b8\Http\Response
|
- User
|
||||||
arguments: []
|
storage.project:
|
||||||
config:
|
class: PHPCI\Store\Base\ProjectStore
|
||||||
class: PHPCI\Config
|
factory: [%storage.factory%, getStore]
|
||||||
arguments: [%config_file%]
|
arguments:
|
||||||
application:
|
- Project
|
||||||
class: PHPCI\Application
|
storage.build:
|
||||||
arguments: [@config, @http.request, @http.response, @store.user, @store.project]
|
class: PHPCI\Store\Base\BuildStore
|
||||||
|
factory: [%storage.factory%, getStore]
|
||||||
|
arguments:
|
||||||
|
- Build
|
||||||
|
storage.build_meta:
|
||||||
|
class: PHPCI\Store\Base\BuildMetaStore
|
||||||
|
factory: [%storage.factory%, getStore]
|
||||||
|
arguments:
|
||||||
|
- BuildMeta
|
||||||
|
http.request:
|
||||||
|
class: b8\Http\Request
|
||||||
|
arguments: []
|
||||||
|
http.response:
|
||||||
|
class: b8\Http\Response
|
||||||
|
arguments: []
|
||||||
|
config:
|
||||||
|
class: PHPCI\Config
|
||||||
|
arguments: [%config_file%]
|
||||||
|
application:
|
||||||
|
class: PHPCI\Application
|
||||||
|
arguments: [@config, @http.request, @http.response, @storage.user, @storage.project]
|
||||||
|
|
4
vars.php
4
vars.php
|
@ -8,7 +8,7 @@ if (!defined('APPLICATION_PATH')) {
|
||||||
|
|
||||||
// Define our PHPCI_URL, if not already defined:
|
// Define our PHPCI_URL, if not already defined:
|
||||||
if (!defined('PHPCI_URL')) {
|
if (!defined('PHPCI_URL')) {
|
||||||
define('PHPCI_URL', $container['config']->get('phpci.url'));
|
define('PHPCI_URL', $container->get('config')->get('phpci.url'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define PHPCI_BIN_DIR
|
// Define PHPCI_BIN_DIR
|
||||||
|
@ -38,5 +38,5 @@ if (!defined('IS_WIN')) {
|
||||||
// If an environment variable is set defining our config location, use that
|
// If an environment variable is set defining our config location, use that
|
||||||
// otherwise fall back to PHPCI/config.yml.
|
// otherwise fall back to PHPCI/config.yml.
|
||||||
if (!defined('PHPCI_CONFIG_FILE')) {
|
if (!defined('PHPCI_CONFIG_FILE')) {
|
||||||
define('PHPCI_CONFIG_FILE', $container['config_file']);
|
define('PHPCI_CONFIG_FILE', $container->get('config_file'));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue