mirror of
https://github.com/nextcloud/server.git
synced 2026-02-25 10:51:41 -05:00
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>
This commit is contained in:
parent
87e638b1f8
commit
d7ecbe32d2
1 changed files with 9 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue