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>
This commit is contained in:
parent
d2b1b02244
commit
67909cf87b
|
@ -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) {
|
public function query($name) {
|
||||||
$name = $this->sanitizeName($name);
|
$name = $this->sanitizeName($name);
|
||||||
|
|
||||||
if ($this->offsetExists($name)) {
|
if ($this->offsetExists($name)) {
|
||||||
return parent::query($name);
|
return parent::query($name);
|
||||||
} else {
|
} else {
|
||||||
if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
|
if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
|
||||||
$segments = explode('\\', $name);
|
|
||||||
if (strtolower($segments[1]) === strtolower($this['AppName'])) {
|
|
||||||
return parent::query($name);
|
|
||||||
}
|
|
||||||
} else if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) {
|
|
||||||
return parent::query($name);
|
return parent::query($name);
|
||||||
} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
|
} else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) {
|
||||||
return parent::query($name);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue