diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-21 10:07:56 +0400 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-30 01:32:27 +0300 |
commit | 10b58b36b8fbc41a1745e051b4bbdce67befa02e (patch) | |
tree | 69fb83a70929ae83062b1392f98e129156ae9a4d | |
parent | d9aef0c397045484a3848106b57de99f7cdeddbe (diff) |
Added PHP-DI + StaticContainer class
-rw-r--r-- | composer.json | 3 | ||||
-rw-r--r-- | composer.lock | 605 | ||||
-rw-r--r-- | config/global.php | 4 | ||||
-rw-r--r-- | core/StaticContainer.php | 62 |
4 files changed, 640 insertions, 34 deletions
diff --git a/composer.json b/composer.json index 24e10fcedc..db9e9c1537 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,8 @@ "tedivm/jshrink": "~0.5.1", "mustangostang/spyc": "~0.5.0", "piwik/device-detector": "~2.0", - "piwik/decompress": "~0.1.1" + "piwik/decompress": "~0.1.1", + "mnapoli/php-di": "~4.4.0" }, "require-dev": { "aws/aws-sdk-php": "2.7.1", diff --git a/composer.lock b/composer.lock index 0180bb1481..7dff61dc40 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": "e8269e35cd792d2a4718e936459423bd", + "hash": "0d42501de65a49e2e8fb665807027443", "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,91 @@ "time": "2013-08-09 17:09:19" }, { + "name": "mnapoli/php-di", + "version": "4.4.0", + "source": { + "type": "git", + "url": "https://github.com/mnapoli/PHP-DI.git", + "reference": "556e3be63a821bbad0585a34f634080305392252" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mnapoli/PHP-DI/zipball/556e3be63a821bbad0585a34f634080305392252", + "reference": "556e3be63a821bbad0585a34f634080305392252", + "shasum": "" + }, + "require": { + "container-interop/container-interop": "~1.0", + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "mnapoli/phpdocreader": "~1.3", + "myclabs/php-enum": "1.*", + "ocramius/proxy-manager": "~0.3", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "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-14 06:13:26" + }, + { + "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 +396,100 @@ "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": "ocramius/proxy-manager", + "version": "0.5.2", + "source": { + "type": "git", + "url": "https://github.com/Ocramius/ProxyManager.git", + "reference": "0ac0eb3e8e04c7fa75caaf1a43c5405623abf8f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ocramius/ProxyManager/zipball/0ac0eb3e8e04c7fa75caaf1a43c5405623abf8f5", + "reference": "0ac0eb3e8e04c7fa75caaf1a43c5405623abf8f5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "zendframework/zend-code": ">2.2.5,<3.0" + }, + "require-dev": { + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "1.5.*" + }, + "suggest": { + "ocramius/generated-hydrator": "To have very fast object to array to object conversion for ghost objects", + "zendframework/zend-json": "To have the JsonRpc adapter (Remote Object feature)", + "zendframework/zend-soap": "To have the Soap adapter (Remote Object feature)", + "zendframework/zend-stdlib": "To use the hydrator proxy", + "zendframework/zend-xmlrpc": "To have the XmlRpc adapter (Remote Object feature)" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "ProxyManager\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A library providing utilities to generate, instantiate and generally operate with Object Proxies", + "homepage": "https://github.com/Ocramius/ProxyManager", + "keywords": [ + "aop", + "lazy loading", + "proxy", + "proxy pattern", + "service proxies" + ], + "time": "2014-09-28 14:18:11" + }, + { "name": "piwik/decompress", "version": "0.1.1", "source": { @@ -178,17 +573,17 @@ }, { "name": "symfony/console", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661" + "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/ca053eaa031c93afb68a71e4eb1f4168dfd4a661", - "reference": "ca053eaa031c93afb68a71e4eb1f4168dfd4a661", + "url": "https://api.github.com/repos/symfony/Console/zipball/6f177fca24200a5b97aef5ce7a5c98124a0f0db0", + "reference": "6f177fca24200a5b97aef5ce7a5c98124a0f0db0", "shasum": "" }, "require": { @@ -229,7 +624,7 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-09-25 09:53:56" + "time": "2014-10-05 13:57:04" }, { "name": "tedivm/jshrink", @@ -274,16 +669,16 @@ }, { "name": "twig/twig", - "version": "v1.16.1", + "version": "v1.16.2", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "7c4c01dcf578523cfcddf383641a4f12790270ec" + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/7c4c01dcf578523cfcddf383641a4f12790270ec", - "reference": "7c4c01dcf578523cfcddf383641a4f12790270ec", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/42f758d9fe2146d1f0470604fc05ee43580873fc", + "reference": "42f758d9fe2146d1f0470604fc05ee43580873fc", "shasum": "" }, "require": { @@ -327,7 +722,151 @@ "keywords": [ "templating" ], - "time": "2014-10-10 14:09:53" + "time": "2014-10-17 12:53:44" + }, + { + "name": "zendframework/zend-code", + "version": "2.3.3", + "target-dir": "Zend/Code", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendCode.git", + "reference": "78ea301533dd05f1c1759e8928d119804900446b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendCode/zipball/78ea301533dd05f1c1759e8928d119804900446b", + "reference": "78ea301533dd05f1c1759e8928d119804900446b", + "shasum": "" + }, + "require": { + "php": ">=5.3.23", + "zendframework/zend-eventmanager": "self.version" + }, + "require-dev": { + "doctrine/common": ">=2.1", + "zendframework/zend-stdlib": "self.version" + }, + "suggest": { + "doctrine/common": "Doctrine\\Common >=2.1 for annotation features", + "zendframework/zend-stdlib": "Zend\\Stdlib component" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Code\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "provides facilities to generate arbitrary code using an object oriented interface", + "homepage": "https://github.com/zendframework/zf2", + "keywords": [ + "code", + "zf2" + ], + "time": "2014-09-16 22:58:11" + }, + { + "name": "zendframework/zend-eventmanager", + "version": "2.3.3", + "target-dir": "Zend/EventManager", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendEventManager.git", + "reference": "4110fe64b10616b9bb71429a206d8e9e6d99e3ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendEventManager/zipball/4110fe64b10616b9bb71429a206d8e9e6d99e3ba", + "reference": "4110fe64b10616b9bb71429a206d8e9e6d99e3ba", + "shasum": "" + }, + "require": { + "php": ">=5.3.23", + "zendframework/zend-stdlib": "self.version" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\EventManager\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zf2", + "keywords": [ + "eventmanager", + "zf2" + ], + "time": "2014-09-16 22:58:11" + }, + { + "name": "zendframework/zend-stdlib", + "version": "2.3.3", + "target-dir": "Zend/Stdlib", + "source": { + "type": "git", + "url": "https://github.com/zendframework/Component_ZendStdlib.git", + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zendframework/Component_ZendStdlib/zipball/fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", + "reference": "fa33e6647f830d0d2a1cb451efcdfe1bb9a66c33", + "shasum": "" + }, + "require": { + "php": ">=5.3.23" + }, + "require-dev": { + "zendframework/zend-eventmanager": "self.version", + "zendframework/zend-serializer": "self.version", + "zendframework/zend-servicemanager": "self.version" + }, + "suggest": { + "zendframework/zend-eventmanager": "To support aggregate hydrator usage", + "zendframework/zend-serializer": "Zend\\Serializer component", + "zendframework/zend-servicemanager": "To support hydrator plugin manager usage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3-dev", + "dev-develop": "2.4-dev" + } + }, + "autoload": { + "psr-0": { + "Zend\\Stdlib\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "homepage": "https://github.com/zendframework/zf2", + "keywords": [ + "stdlib", + "zf2" + ], + "time": "2014-09-16 22:58:11" } ], "packages-dev": [ @@ -920,16 +1459,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.3.3", + "version": "4.3.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4" + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4", - "reference": "5a0bc4dcbb7340c0a9a9bc3507854a67c564edc4", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/23e4e0310f037aae873cc81b8658dbbb82878f71", + "reference": "23e4e0310f037aae873cc81b8658dbbb82878f71", "shasum": "" }, "require": { @@ -940,7 +1479,7 @@ "ext-spl": "*", "php": ">=5.3.3", "phpunit/php-code-coverage": "~2.0", - "phpunit/php-file-iterator": "~1.3.1", + "phpunit/php-file-iterator": "~1.3.2", "phpunit/php-text-template": "~1.2", "phpunit/php-timer": "~1.0.2", "phpunit/phpunit-mock-objects": "~2.3", @@ -990,7 +1529,7 @@ "testing", "xunit" ], - "time": "2014-10-16 16:53:00" + "time": "2014-10-22 11:43:12" }, { "name": "phpunit/phpunit-mock-objects", @@ -1165,16 +1704,16 @@ }, { "name": "sebastian/environment", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7" + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", - "reference": "6288ebbf6fa3ed2b2ff2d69c356fbaaf4f0971a7", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0d9bf79554d2a999da194a60416c15cf461eb67d", + "reference": "0d9bf79554d2a999da194a60416c15cf461eb67d", "shasum": "" }, "require": { @@ -1186,7 +1725,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "1.2.x-dev" } }, "autoload": { @@ -1211,7 +1750,7 @@ "environment", "hhvm" ], - "time": "2014-10-07 09:23:16" + "time": "2014-10-22 06:38:05" }, { "name": "sebastian/exporter", @@ -1315,17 +1854,17 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46" + "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f6281337bf5f985f585d1db6a83adb05ce531f46", - "reference": "f6281337bf5f985f585d1db6a83adb05ce531f46", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/804eb28dbbfba9ffdab21fe2066744906cea2212", + "reference": "804eb28dbbfba9ffdab21fe2066744906cea2212", "shasum": "" }, "require": { @@ -1368,21 +1907,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2014-09-28 15:56:11" + "time": "2014-10-01 15:43:05" }, { "name": "symfony/yaml", - "version": "v2.5.5", + "version": "v2.5.6", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96" + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/b1dbc53593b98c2d694ebf383660ac9134d30b96", - "reference": "b1dbc53593b98c2d694ebf383660ac9134d30b96", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/2d9f527449cabfa8543dd7fa3a466d6ae83d6726", + "reference": "2d9f527449cabfa8543dd7fa3a466d6ae83d6726", "shasum": "" }, "require": { @@ -1415,7 +1954,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2014-09-22 09:14:18" + "time": "2014-10-01 05:50:18" } ], "aliases": [], 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/StaticContainer.php b/core/StaticContainer.php new file mode 100644 index 0000000000..6667f9d302 --- /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 Interop\Container\ContainerInterface; + +/** + * 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 ContainerInterface + */ + 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($cache); + // $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(); + } +} |