diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-03-08 10:31:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-08 10:31:10 +0100 |
commit | ec5f4200ad402a7ee9fc68c677c6cea8d4437052 (patch) | |
tree | 81652d9bea25bf151fba3d3f882f1d4802e32663 /lib/private | |
parent | 592975bf6429f6718ba361315c639b0bf8cfc8c8 (diff) | |
parent | e13253c66ac4bbe5a73db08ffb9244e7f9669f19 (diff) | |
download | nextcloud-server-ec5f4200ad402a7ee9fc68c677c6cea8d4437052.tar.gz nextcloud-server-ec5f4200ad402a7ee9fc68c677c6cea8d4437052.zip |
Merge pull request #14548 from nextcloud/bugfix/noid/avoid-duplicate-container-creation
Avoid duplicate App container creation
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/ServerContainer.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/private/ServerContainer.php b/lib/private/ServerContainer.php index e1447d2f06b..8c2b49bb085 100644 --- a/lib/private/ServerContainer.php +++ b/lib/private/ServerContainer.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -57,7 +58,7 @@ class ServerContainer extends SimpleContainer { * @param string $appName * @param string $appNamespace */ - public function registerNamespace($appName, $appNamespace) { + public function registerNamespace(string $appName, string $appNamespace): void { // Cut of OCA\ and lowercase $appNamespace = strtolower(substr($appNamespace, strrpos($appNamespace, '\\') + 1)); $this->namespaces[$appNamespace] = $appName; @@ -67,17 +68,30 @@ class ServerContainer extends SimpleContainer { * @param string $appName * @param DIContainer $container */ - public function registerAppContainer($appName, DIContainer $container) { + public function registerAppContainer(string $appName, DIContainer $container): void { $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container; } /** + * @param string $appName + * @return DIContainer + * @throws QueryException + */ + public function getRegisteredAppContainer(string $appName): DIContainer { + if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) { + return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))]; + } + + throw new QueryException(); + } + + /** * @param string $namespace * @param string $sensitiveNamespace * @return DIContainer * @throws QueryException */ - protected function getAppContainer($namespace, $sensitiveNamespace) { + protected function getAppContainer(string $namespace, string $sensitiveNamespace): DIContainer { if (isset($this->appContainers[$namespace])) { return $this->appContainers[$namespace]; } |