diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-21 20:53:37 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-03-21 20:53:37 +0100 |
commit | 67909cf87bf17e6369d7e244aa956060aa40d25d (patch) | |
tree | 004e04192454a967ea95835381372ccdb0bee8b1 | |
parent | d2b1b0224437e521094dd251bc84bc93d1e338b1 (diff) | |
download | nextcloud-server-67909cf87bf17e6369d7e244aa956060aa40d25d.tar.gz nextcloud-server-67909cf87bf17e6369d7e244aa956060aa40d25d.zip |
Make DI work for all apps
As stated in https://github.com/nextcloud/server/pull/3901#issuecomment-288135309
appid's don't have to match the namespace.
Work around this
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 06825d2dd5e..9d27aff4869 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -373,21 +373,28 @@ class DIContainer extends SimpleContainer implements IAppContainer { }); } + private function getFallbackNamespace($name) { + $segments = explode('\\', $name); + if (count($segments) >= 2) { + return $segments[0] . '\\' . ucfirst(strtolower($segments[1])); + } else { + return null; + } + } + public function query($name) { $name = $this->sanitizeName($name); if ($this->offsetExists($name)) { return parent::query($name); } else { - if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) { - $segments = explode('\\', $name); - if (strtolower($segments[1]) === strtolower($this['AppName'])) { - return parent::query($name); - } - } else if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { + if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { return parent::query($name); } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { return parent::query($name); + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName'])) === 0 || + $this->getFallbackNamespace($name) === \OC\AppFramework\App::buildAppNamespace($this['AppName'])) { + return parent::query($name); } } |