mirror of
https://github.com/nextcloud/server.git
synced 2026-06-11 09:42:09 -04:00
Avoid duplicate App container creation
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
a4b34abe45
commit
c5ab74348c
2 changed files with 19 additions and 1 deletions
|
|
@ -71,6 +71,19 @@ class ServerContainer extends SimpleContainer {
|
|||
$this->appContainers[strtolower(App::buildAppNamespace($appName, ''))] = $container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @return DIContainer
|
||||
* @throws QueryException
|
||||
*/
|
||||
public function getRegisteredAppContainer(string $appName) {
|
||||
if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName, ''))])) {
|
||||
return $this->appContainers[strtolower(App::buildAppNamespace($appName, ''))];
|
||||
}
|
||||
|
||||
throw new QueryException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $namespace
|
||||
* @param string $sensitiveNamespace
|
||||
|
|
|
|||
|
|
@ -66,11 +66,16 @@ class App {
|
|||
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param array $urlParams an array with variables extracted from the routes
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public function __construct(string $appName, array $urlParams = []) {
|
||||
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams);
|
||||
try {
|
||||
$this->container = \OC::$server->getRegisteredAppContainer($appName);
|
||||
} catch (QueryException $e) {
|
||||
$this->container = new \OC\AppFramework\DependencyInjection\DIContainer($appName, $urlParams);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue