]> source.dussan.org Git - nextcloud-server.git/commitdiff
Update Pimple to V3.0
authorThomas Müller <thomas.mueller@tmit.eu>
Mon, 3 Nov 2014 12:10:03 +0000 (13:10 +0100)
committerThomas Müller <thomas.mueller@tmit.eu>
Mon, 3 Nov 2014 15:57:16 +0000 (16:57 +0100)
3rdparty
lib/base.php
lib/private/appframework/dependencyinjection/dicontainer.php
lib/private/appframework/utility/simplecontainer.php

index c37dc06ce2906813dec3296d1a58c1628c206a31..17cdabdae0168bd678f859345b0b20a9ae7c9646 160000 (submodule)
--- a/3rdparty
+++ b/3rdparty
@@ -1 +1 @@
-Subproject commit c37dc06ce2906813dec3296d1a58c1628c206a31
+Subproject commit 17cdabdae0168bd678f859345b0b20a9ae7c9646
index d428d45d90a06f41dd9a9e6a11cda3df35b19378..7fa53c3a074f83df9d2af0032d3b99de0785842f 100644 (file)
@@ -457,8 +457,7 @@ class OC {
                // setup 3rdparty autoloader
                $vendorAutoLoad = OC::$THIRDPARTYROOT . '/3rdparty/autoload.php';
                if (file_exists($vendorAutoLoad)) {
-                       $loader = require_once $vendorAutoLoad;
-                       $loader->add('Pimple',OC::$THIRDPARTYROOT . '/3rdparty/Pimple');
+                       require_once $vendorAutoLoad;
                } else {
                        OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
                        OC_Template::printErrorPage('Composer autoloader not found, unable to continue.');
index f7fee347215cf6f92b2288699eb4cf5acb2c595c..98525ed3202de24107c62cfec3cd7510366cd7be 100644 (file)
@@ -59,14 +59,14 @@ class DIContainer extends SimpleContainer implements IAppContainer{
 
                $this->registerParameter('ServerContainer', \OC::$server);
 
-               $this['API'] = $this->share(function($c){
+               $this->registerService('API', function($c){
                        return new API($c['AppName']);
                });
 
                /**
                 * Http
                 */
-               $this['Request'] = $this->share(function($c) {
+               $this->registerService('Request', function($c) {
                        /** @var $c SimpleContainer */
                        /** @var $server SimpleContainer */
                        $server = $c->query('ServerContainer');
@@ -75,7 +75,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                        return $server->getRequest();
                });
 
-               $this['Protocol'] = $this->share(function($c){
+               $this->registerService('Protocol', function($c){
                        if(isset($_SERVER['SERVER_PROTOCOL'])) {
                                return new Http($_SERVER, $_SERVER['SERVER_PROTOCOL']);
                        } else {
@@ -83,7 +83,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                        }
                });
 
-               $this['Dispatcher'] = $this->share(function($c) {
+               $this->registerService('Dispatcher', function($c) {
                        return new Dispatcher(
                                $c['Protocol'],
                                $c['MiddlewareDispatcher'],
@@ -97,7 +97,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                 * Middleware
                 */
                $app = $this;
-               $this['SecurityMiddleware'] = $this->share(function($c) use ($app){
+               $this->registerService('SecurityMiddleware', function($c) use ($app){
                        return new SecurityMiddleware(
                                $c['Request'],
                                $c['ControllerMethodReflector'],
@@ -110,14 +110,14 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                        );
                });
 
-               $this['CORSMiddleware'] = $this->share(function($c) {
+               $this->registerService('CORSMiddleware', function($c) {
                        return new CORSMiddleware(
                                $c['Request'],
                                $c['ControllerMethodReflector']
                        );
                });
 
-               $this['SessionMiddleware'] = $this->share(function($c) use ($app) {
+               $this->registerService('SessionMiddleware', function($c) use ($app) {
                        return new SessionMiddleware(
                                $c['Request'],
                                $c['ControllerMethodReflector'],
@@ -126,7 +126,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                });
 
                $middleWares = &$this->middleWares;
-               $this['MiddlewareDispatcher'] = $this->share(function($c) use (&$middleWares) {
+               $this->registerService('MiddlewareDispatcher', function($c) use (&$middleWares) {
                        $dispatcher = new MiddlewareDispatcher();
                        $dispatcher->registerMiddleware($c['SecurityMiddleware']);
                        $dispatcher->registerMiddleware($c['CORSMiddleware']);
@@ -143,11 +143,11 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                /**
                 * Utilities
                 */
-               $this['TimeFactory'] = $this->share(function($c){
+               $this->registerService('TimeFactory', function($c){
                        return new TimeFactory();
                });
 
-               $this['ControllerMethodReflector'] = $this->share(function($c) {
+               $this->registerService('ControllerMethodReflector', function($c) {
                        return new ControllerMethodReflector();
                });
 
index a2d90138dfa0a22bedd9601eb2ff858ca0b526ea..c6effed5b4b8c9fe628dd41938a75927959c2c5e 100644 (file)
@@ -7,7 +7,7 @@ namespace OC\AppFramework\Utility;
  *
  * SimpleContainer is a simple implementation of IContainer on basis of \Pimple
  */
-class SimpleContainer extends \Pimple implements \OCP\IContainer {
+class SimpleContainer extends \Pimple\Container implements \OCP\IContainer {
 
        /**
         * @param string $name name of the service to query for
@@ -35,10 +35,13 @@ class SimpleContainer extends \Pimple implements \OCP\IContainer {
         * @param bool $shared
         */
        function registerService($name, \Closure $closure, $shared = true) {
+               if (!empty($this[$name]))  {
+                       unset($this[$name]);
+               }
                if ($shared) {
-                       $this[$name] = \Pimple::share($closure);
-               } else {
                        $this[$name] = $closure;
+               } else {
+                       $this[$name] = parent::factory($closure);
                }
        }
 }