Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LEGALNOTICE4
-rw-r--r--composer.json3
-rw-r--r--composer.lock343
-rw-r--r--config/global.php4
-rw-r--r--core/FrontController.php11
-rw-r--r--core/StaticContainer.php62
6 files changed, 420 insertions, 7 deletions
diff --git a/LEGALNOTICE b/LEGALNOTICE
index 20c372a493..c438523071 100644
--- a/LEGALNOTICE
+++ b/LEGALNOTICE
@@ -236,6 +236,10 @@ THIRD-PARTY COMPONENTS AND LIBRARIES
Link: https://github.com/ccampbell/mousetrap
License: Apache 2.0
+ Name: PHP-DI
+ Link: http://php-di.org/
+ License: MIT (Expat)
+
THIRD-PARTY CONTENT
diff --git a/composer.json b/composer.json
index 47886d558b..91fffba957 100644
--- a/composer.json
+++ b/composer.json
@@ -44,7 +44,8 @@
"mustangostang/spyc": "~0.5.0",
"piwik/device-detector": "~2.0",
"piwik/decompress": "~0.1.1",
- "piwik/network": "~0.1.0"
+ "piwik/network": "~0.1.0",
+ "mnapoli/php-di": "5.0.x-dev"
},
"require-dev": {
"aws/aws-sdk-php": "2.7.1",
diff --git a/composer.lock b/composer.lock
index f68cc7508c..3221f0ad25 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,9 +4,225 @@
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "7fe1e059c2372246332679bfd15ca4a6",
+ "hash": "92499fc432a629fefcd5c1b912e44d9c",
"packages": [
{
+ "name": "container-interop/container-interop",
+ "version": "1.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/container-interop/container-interop.git",
+ "reference": "b4274c871bfd1ae8d8e527ba11734f4df1573e48"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/container-interop/container-interop/zipball/b4274c871bfd1ae8d8e527ba11734f4df1573e48",
+ "reference": "b4274c871bfd1ae8d8e527ba11734f4df1573e48",
+ "shasum": ""
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "Interop\\Container\\": "src/Interop/Container/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Promoting the interoperability of container objects (DIC, SL, etc.)",
+ "time": "2014-03-16 14:50:05"
+ },
+ {
+ "name": "doctrine/annotations",
+ "version": "v1.2.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/annotations.git",
+ "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/annotations/zipball/6a6bec0670bb6e71a263b08bc1b98ea242928633",
+ "reference": "6a6bec0670bb6e71a263b08bc1b98ea242928633",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/lexer": "1.*",
+ "php": ">=5.3.2"
+ },
+ "require-dev": {
+ "doctrine/cache": "1.*",
+ "phpunit/phpunit": "4.*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.3.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\Annotations\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Docblock Annotations Parser",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "annotations",
+ "docblock",
+ "parser"
+ ],
+ "time": "2014-09-25 16:45:30"
+ },
+ {
+ "name": "doctrine/cache",
+ "version": "v1.3.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/cache.git",
+ "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/cache/zipball/cf483685798a72c93bf4206e3dd6358ea07d64e7",
+ "reference": "cf483685798a72c93bf4206e3dd6358ea07d64e7",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "conflict": {
+ "doctrine/common": ">2.2,<2.4"
+ },
+ "require-dev": {
+ "phpunit/phpunit": ">=3.7",
+ "satooshi/php-coveralls": "~0.6"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\Cache\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Caching library offering an object-oriented API for many cache backends",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "cache",
+ "caching"
+ ],
+ "time": "2014-09-17 14:24:04"
+ },
+ {
+ "name": "doctrine/lexer",
+ "version": "v1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/lexer.git",
+ "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/lexer/zipball/2f708a85bb3aab5d99dab8be435abd73e0b18acb",
+ "reference": "2f708a85bb3aab5d99dab8be435abd73e0b18acb",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\Lexer\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com",
+ "homepage": "http://www.instaclick.com"
+ },
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com",
+ "homepage": "https://github.com/schmittjoh",
+ "role": "Developer of wrapped JMSSerializerBundle"
+ }
+ ],
+ "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "lexer",
+ "parser"
+ ],
+ "time": "2013-01-12 18:59:04"
+ },
+ {
"name": "leafo/lessphp",
"version": "v0.4.0",
"source": {
@@ -48,6 +264,99 @@
"time": "2013-08-09 17:09:19"
},
{
+ "name": "mnapoli/php-di",
+ "version": "5.0.x-dev",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mnapoli/PHP-DI.git",
+ "reference": "018126838b9c3922ee23afff2d779af3d88f6740"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mnapoli/PHP-DI/zipball/018126838b9c3922ee23afff2d779af3d88f6740",
+ "reference": "018126838b9c3922ee23afff2d779af3d88f6740",
+ "shasum": ""
+ },
+ "require": {
+ "container-interop/container-interop": "~1.0",
+ "doctrine/annotations": "1.*",
+ "doctrine/cache": "1.*",
+ "mnapoli/phpdocreader": "~1.3",
+ "myclabs/php-enum": "1.*",
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "ocramius/proxy-manager": "~0.3",
+ "phpunit/phpunit": "~4.0"
+ },
+ "suggest": {
+ "ocramius/proxy-manager": "Install it if you want to use lazy injection"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "5.0.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "DI\\": "src/",
+ "IntegrationTests\\": "tests/",
+ "UnitTests\\": "tests/"
+ },
+ "files": [
+ "src/DI/functions.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHP-DI is a Container that makes Dependency Injection as practical as possible in PHP",
+ "homepage": "http://mnapoli.github.com/PHP-DI/",
+ "keywords": [
+ "container",
+ "dependency injection",
+ "di"
+ ],
+ "time": "2014-10-31 00:34:51"
+ },
+ {
+ "name": "mnapoli/phpdocreader",
+ "version": "1.3.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/mnapoli/PhpDocReader.git",
+ "reference": "8a6e123fd1ce54f7fcbd71747b3bf04e465da229"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/mnapoli/PhpDocReader/zipball/8a6e123fd1ce54f7fcbd71747b3bf04e465da229",
+ "reference": "8a6e123fd1ce54f7fcbd71747b3bf04e465da229",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/annotations": "1.*",
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "PhpDocReader": "src/",
+ "UnitTest": "tests/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "keywords": [
+ "phpdoc",
+ "reflection"
+ ],
+ "time": "2014-08-21 08:20:45"
+ },
+ {
"name": "mustangostang/spyc",
"version": "0.5.1",
"source": {
@@ -95,6 +404,37 @@
"time": "2013-02-21 10:52:01"
},
{
+ "name": "myclabs/php-enum",
+ "version": "1.2.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/myclabs/php-enum.git",
+ "reference": "b52c2f215f5b251693369309ea7f537f9d92ec5e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/myclabs/php-enum/zipball/b52c2f215f5b251693369309ea7f537f9d92ec5e",
+ "reference": "b52c2f215f5b251693369309ea7f537f9d92ec5e",
+ "shasum": ""
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "MyCLabs": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHP Enum implementation",
+ "homepage": "http://github.com/myclabs/php-enum",
+ "keywords": [
+ "enum"
+ ],
+ "time": "2013-11-11 18:29:08"
+ },
+ {
"name": "piwik/decompress",
"version": "0.1.1",
"source": {
@@ -1455,6 +1795,7 @@
],
"minimum-stability": "stable",
"stability-flags": {
+ "mnapoli/php-di": 20,
"facebook/xhprof": 20
},
"prefer-stable": false,
diff --git a/config/global.php b/config/global.php
new file mode 100644
index 0000000000..9a25907242
--- /dev/null
+++ b/config/global.php
@@ -0,0 +1,4 @@
+<?php
+
+return array(
+);
diff --git a/core/FrontController.php b/core/FrontController.php
index 0fa143d4b6..16d5930fe2 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -19,7 +19,6 @@ use Piwik\Plugin\Report;
use Piwik\Plugin\Widgets;
use Piwik\Plugins\CoreAdminHome\CustomLogo;
use Piwik\Session;
-use Piwik\Plugins\CoreHome\Controller as CoreHomeController;
/**
* This singleton dispatches requests to the appropriate plugin Controller.
@@ -113,6 +112,8 @@ class FrontController extends Singleton
protected function makeController($module, $action, &$parameters)
{
+ $container = StaticContainer::getContainer();
+
$controllerClassName = $this->getClassNameController($module);
// TRY TO FIND ACTION IN CONTROLLER
@@ -120,7 +121,7 @@ class FrontController extends Singleton
$class = $this->getClassNameController($module);
/** @var $controller Controller */
- $controller = new $class;
+ $controller = $container->make($class);
$controllerAction = $action;
if ($controllerAction === false) {
@@ -146,7 +147,7 @@ class FrontController extends Singleton
$parameters['widgetModule'] = $module;
$parameters['widgetMethod'] = $action;
- return array(new CoreHomeController(), 'renderWidget');
+ return array($container->make('Piwik\Plugins\CoreHome\Controller'), 'renderWidget');
}
// TRY TO FIND ACTION IN REPORT
@@ -157,7 +158,7 @@ class FrontController extends Singleton
$parameters['reportModule'] = $module;
$parameters['reportAction'] = $action;
- return array(new CoreHomeController(), 'renderReportWidget');
+ return array($container->make('Piwik\Plugins\CoreHome\Controller'), 'renderReportWidget');
}
if (!empty($action) && Report::PREFIX_ACTION_IN_MENU === substr($action, 0, strlen(Report
@@ -169,7 +170,7 @@ class FrontController extends Singleton
$parameters['reportModule'] = $module;
$parameters['reportAction'] = $reportAction;
- return array(new CoreHomeController(), 'renderReportMenu');
+ return array($container->make('Piwik\Plugins\CoreHome\Controller'), 'renderReportMenu');
}
}
diff --git a/core/StaticContainer.php b/core/StaticContainer.php
new file mode 100644
index 0000000000..35f486d801
--- /dev/null
+++ b/core/StaticContainer.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Piwik - free/libre analytics platform
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ */
+
+namespace Piwik;
+
+use DI\Container;
+use DI\ContainerBuilder;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * This class provides a static access to the container.
+ *
+ * @deprecated This class is introduced only to keep BC with the current static architecture. It will be removed in 3.0.
+ * - it is global state (that class makes the container a global variable)
+ * - using the container directly is the "service locator" anti-pattern (which is not dependency injection)
+ */
+class StaticContainer
+{
+ /**
+ * @var Container
+ */
+ private static $container;
+
+ /**
+ * @return Container
+ */
+ public static function getContainer()
+ {
+ if (self::$container === null) {
+ self::$container = self::createContainer();
+ }
+
+ return self::$container;
+ }
+
+ /**
+ * @link http://php-di.org/doc/container-configuration.html
+ */
+ private static function createContainer()
+ {
+ $builder = new ContainerBuilder();
+
+ // TODO add cache
+ $builder->setDefinitionCache(new ArrayCache());
+ // $builder->writeProxiesToFile(true, PIWIK_USER_PATH . '/tmp/proxies');
+
+ // Global config
+ $builder->addDefinitions(PIWIK_USER_PATH . '/config/global.php');
+
+ // User config
+ if (file_exists(PIWIK_USER_PATH . '/config/config.php')) {
+ $builder->addDefinitions(PIWIK_USER_PATH . '/config/config.php');
+ }
+
+ return $builder->build();
+ }
+}