Skip to content

Commit

Permalink
Make DI work for all apps
Browse files Browse the repository at this point in the history
As stated in #3901 (comment)
appid's don't have to match the namespace.

Work around this

Signed-off-by: Roeland Jago Douma <[email protected]>
  • Loading branch information
rullzer committed Mar 21, 2017
1 parent d2b1b02 commit 67909cf
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/private/AppFramework/DependencyInjection/DIContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,21 +373,28 @@ public function registerCapability($serviceName) {
});
}

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);
}
}

Expand Down

0 comments on commit 67909cf

Please sign in to comment.