summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-12-18 11:44:10 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-12-18 13:45:07 +0100
commit1f197134c87836167142cc766bdaab572fb73b8d (patch)
tree090ac36ae08bce2f53c8954099e2da9504e7a341
parent412e4ed3f669b61f155b5ef1bc6d50168f5ea131 (diff)
downloadnextcloud-server-1f197134c87836167142cc766bdaab572fb73b8d.tar.gz
nextcloud-server-1f197134c87836167142cc766bdaab572fb73b8d.zip
Look up services in the app container before trying the core container
-rw-r--r--lib/private/servercontainer.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/private/servercontainer.php b/lib/private/servercontainer.php
index 469fd6475e2..856e3f9b495 100644
--- a/lib/private/servercontainer.php
+++ b/lib/private/servercontainer.php
@@ -62,4 +62,28 @@ class ServerContainer extends SimpleContainer {
return new DIContainer($appName);
}
+
+ /**
+ * @param string $name name of the service to query for
+ * @return mixed registered service for the given $name
+ * @throws QueryException if the query could not be resolved
+ */
+ public function query($name) {
+ $name = $this->sanitizeName($name);
+
+ // In case the service starts with OCA\ we try to find the service in
+ // the apps container first.
+ if (strpos($name, 'OCA\\') === 0 && substr_count($name, '\\') >= 2) {
+ $segments = explode('\\', $name);
+ $appContainer = $this->getAppContainer(strtolower($segments[0]));
+ try {
+ return $appContainer->query($name);
+ } catch (QueryException $e) {
+ // Didn't find the service in the respective app container,
+ // ignore it and fall back to the core container.
+ }
+ }
+
+ return parent::query($name);
+ }
}