diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-19 23:14:47 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-21 08:52:20 +0100 |
commit | 21641302a97815c2779f65ffd9efc95cf314e48d (patch) | |
tree | 2a963b50b2f9220c58882192405e660b02d7d104 /lib/private/AppFramework | |
parent | 7cece61ff66df60e2df258285049b6009e921197 (diff) | |
download | nextcloud-server-21641302a97815c2779f65ffd9efc95cf314e48d.tar.gz nextcloud-server-21641302a97815c2779f65ffd9efc95cf314e48d.zip |
Add DI intergration tests
* Moved some interface definitions to Server.php (more to come)
* Build/Query only for existing classes in the AppContainer
* Build/Query only for classes of the App in the AppContainer
* Offload other stuff to the servercontainer
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 939e45dcd35..3bfc64e85b5 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -45,6 +45,7 @@ use OC\AppFramework\Middleware\SessionMiddleware; use OC\AppFramework\Utility\SimpleContainer; use OC\Core\Middleware\TwoFactorMiddleware; use OC\RichObjectStrings\Validator; +use OC\ServerContainer; use OCP\AppFramework\IApi; use OCP\AppFramework\IAppContainer; use OCP\AppFramework\QueryException; @@ -62,24 +63,25 @@ class DIContainer extends SimpleContainer implements IAppContainer { */ private $middleWares = array(); - /** @var IServerContainer */ + /** @var ServerContainer */ private $server; /** * Put your class dependencies in here * @param string $appName the name of the app * @param array $urlParams - * @param IServerContainer $server + * @param ServerContainer $server */ - public function __construct($appName, $urlParams = array(), IServerContainer $server = null){ + public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ parent::__construct(); $this['AppName'] = $appName; $this['urlParams'] = $urlParams; /** @var \OC\ServerContainer $server */ if ($server === null) { - $this->server = \OC::$server; + $server = \OC::$server; } + $this->server = $server; $this->server->registerAppContainer($appName, $this); // aliases @@ -570,13 +572,13 @@ class DIContainer extends SimpleContainer implements IAppContainer { public function query($name) { $name = $this->sanitizeName($name); - try { + if ($this->offsetExists($name)) { return parent::query($name); - } catch (QueryException $e) { + } else { if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { $segments = explode('\\', $name); if (strtolower($segments[1]) === strtolower($this['AppName'])) { - throw new QueryException(); + return parent::query($name); } } } |