use OC\AppFramework\Core\API;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
use OC\AppFramework\Middleware\Security\SecurityMiddleware;
+use OC\AppFramework\Utility\SimpleContainer;
use OC\AppFramework\Utility\TimeFactory;
-// register 3rdparty autoloaders
-require_once __DIR__ . '/../../../3rdparty/Pimple/Pimple.php';
-
-/**
- * This class extends Pimple (http://pimple.sensiolabs.org/) for reusability
- * To use this class, extend your own container from this. Should you require it
- * you can overwrite the dependencies with your own classes by simply redefining
- * a dependency
- */
-class DIContainer extends \Pimple {
+class DIContainer extends SimpleContainer {
/**
* Http
*/
$this['Request'] = $this->share(function($c) {
- $params = json_decode(file_get_contents('php://input'), true);
- $params = is_array($params) ? $params: array();
+
+ $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(
--- /dev/null
+<?php
+
+namespace OC\AppFramework\Utility;
+
+// register 3rdparty autoloaders
+require_once __DIR__ . '/../../../3rdparty/Pimple/Pimple.php';
+
+/**
+ * Class SimpleContainer
+ *
+ * SimpleContainer is a simple implementation of IContainer on basis of \Pimple
+ */
+class SimpleContainer extends \Pimple implements \OCP\Core\IContainer {
+
+ /**
+ * @param string $name name of the service to query for
+ * @return object registered service for the given $name
+ */
+ public function query($name) {
+ return $this->offsetGet($name);
+ }
+
+ function registerParameter($name, $value)
+ {
+ $this[$name] = $value;
+ }
+
+ /**
+ * The given closure is call the first time the given service is queried.
+ * The closure has to return the instance for the given service.
+ * Created instance will be cached in case $shared is true.
+ *
+ * @param string $name name of the service to register another backend for
+ * @param callable $closure the closure to be called on service creation
+ */
+ function registerService($name, \Closure $closure, $shared = true)
+ {
+ if ($shared) {
+ $this[$name] = \Pimple::share($closure);
+ } else {
+ $this[$name] = $closure;
+ }
+ }
+}
}
}
+ if (strpos($className, 'OCP\\') === 0) {
+ $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ $relPath = __DIR__ . '/../../../lib/public' . $path;
+
+ if(file_exists($relPath)){
+ require_once $relPath;
+ }
+ }
+
// FIXME: this will most probably not work anymore
if (strpos($className, 'OCA\\') === 0) {