diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-11-16 18:54:25 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-12-07 22:32:04 +0100 |
commit | d7ecbe32d205309f7bf2eaed41890d40cdc5e660 (patch) | |
tree | 50eef10306309367ae490589e7dd2712f416c6d3 /lib/private/AppFramework | |
parent | 87e638b1f8c0e418b491464c4b7dccce0e8a61bf (diff) | |
download | nextcloud-server-d7ecbe32d205309f7bf2eaed41890d40cdc5e660.tar.gz nextcloud-server-d7ecbe32d205309f7bf2eaed41890d40cdc5e660.zip |
Avoid container dance for appName
Sicne the appName is always passed for the DIContainer we can avoid
using the container query logic and instead store and use a property
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/AppFramework')
-rw-r--r-- | lib/private/AppFramework/DependencyInjection/DIContainer.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 4c413a8ae87..5fd363ee963 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -79,6 +79,7 @@ use Psr\Log\LoggerInterface; * @deprecated 20.0.0 */ class DIContainer extends SimpleContainer implements IAppContainer { + private string $appName; /** * @var array @@ -94,8 +95,9 @@ class DIContainer extends SimpleContainer implements IAppContainer { * @param array $urlParams * @param ServerContainer|null $server */ - public function __construct($appName, $urlParams = [], ServerContainer $server = null) { + public function __construct(string $appName, array $urlParams = [], ServerContainer $server = null) { parent::__construct(); + $this->appName = $appName; $this['appName'] = $appName; $this['urlParams'] = $urlParams; @@ -437,6 +439,9 @@ class DIContainer extends SimpleContainer implements IAppContainer { } public function query(string $name, bool $autoload = true) { + if ($name === 'AppName' || $name === 'appName') { + return $this->appName; + } try { return $this->queryNoFallback($name); } catch (QueryException $firstException) { @@ -461,11 +466,11 @@ class DIContainer extends SimpleContainer implements IAppContainer { if ($this->offsetExists($name)) { return parent::query($name); - } elseif ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { + } elseif ($this->appName === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { return parent::query($name); - } elseif ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { + } elseif ($this->appName === 'core' && strpos($name, 'OC\\Core\\') === 0) { return parent::query($name); - } elseif (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { + } elseif (strpos($name, \OC\AppFramework\App::buildAppNamespace($this->appName) . '\\') === 0) { return parent::query($name); } |