]> source.dussan.org Git - nextcloud-server.git/commitdiff
AppFramework:
authorThomas Müller <thomas.mueller@tmit.eu>
Wed, 25 Sep 2013 08:30:48 +0000 (10:30 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Wed, 25 Sep 2013 08:30:48 +0000 (10:30 +0200)
- get request from the server container
- implement registerMiddleWare()
- adding getAppName() to app container

lib/appframework/dependencyinjection/dicontainer.php
lib/public/appframework/iappcontainer.php

index 2ef885d7b2ca7f628807ae5fc7ceaf199d4cdac9..54878266939df1c103500920c0bcc014019c612a 100644 (file)
@@ -34,6 +34,8 @@ use OC\AppFramework\Utility\SimpleContainer;
 use OC\AppFramework\Utility\TimeFactory;
 use OCP\AppFramework\IApi;
 use OCP\AppFramework\IAppContainer;
+use OCP\AppFramework\IMiddleWare;
+use OCP\IServerContainer;
 
 
 class DIContainer extends SimpleContainer implements IAppContainer{
@@ -57,31 +59,10 @@ class DIContainer extends SimpleContainer implements IAppContainer{
                 * Http
                 */
                $this['Request'] = $this->share(function($c) {
-
-                       $params = array();
-
-                       // we json decode the body only in case of content type json
-                       if (isset($_SERVER['CONTENT_TYPE']) && stripos($_SERVER['CONTENT_TYPE'],'json') === true ) {
-                               $params = json_decode(file_get_contents('php://input'), true);
-                               $params = is_array($params) ? $params: array();
-                       }
-
-                       return new Request(
-                               array(
-                                       'get' => $_GET,
-                                       'post' => $_POST,
-                                       'files' => $_FILES,
-                                       'server' => $_SERVER,
-                                       'env' => $_ENV,
-                                       'session' => $_SESSION,
-                                       'cookies' => $_COOKIE,
-                                       'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
-                                                       ? $_SERVER['REQUEST_METHOD']
-                                                       : null,
-                                       'params' => $params,
-                                       'urlParams' => $c['urlParams']
-                               )
-                       );
+                       /** @var $c SimpleContainer */
+                       /** @var $server IServerContainer */
+                       $server = $c->query('ServerContainer');
+                       return $server->getRequest();
                });
 
                $this['Protocol'] = $this->share(function($c){
@@ -138,4 +119,23 @@ class DIContainer extends SimpleContainer implements IAppContainer{
        {
                return $this->query('ServerContainer');
        }
+
+       /**
+        * @param IMiddleWare $middleWare
+        * @return boolean
+        */
+       function registerMiddleWare(IMiddleWare $middleWare) {
+               /** @var $dispatcher MiddlewareDispatcher */
+               $dispatcher = $this->query('MiddlewareDispatcher');
+               $dispatcher->registerMiddleware($middleWare);
+
+       }
+
+       /**
+        * used to return the appname of the set application
+        * @return string the name of your application
+        */
+       function getAppName() {
+               return $this->query('AppName');
+       }
 }
index c8f6229dd9ee23184f7f710e9d2c827bb6fc84f8..7d3b4b3bac7587331ff003322369f205830d6a20 100644 (file)
@@ -33,6 +33,12 @@ use OCP\IContainer;
  */
 interface IAppContainer extends IContainer{
 
+       /**
+        * used to return the appname of the set application
+        * @return string the name of your application
+        */
+       function getAppName();
+
        /**
         * @return IApi
         */
@@ -42,4 +48,10 @@ interface IAppContainer extends IContainer{
         * @return \OCP\IServerContainer
         */
        function getServer();
+
+       /**
+        * @param IMiddleWare $middleWare
+        * @return boolean
+        */
+       function registerMiddleWare(IMiddleWare $middleWare);
 }