Skip to content

Commit e50f4c4

Browse files
authored
Merge pull request #34929 from nextcloud/chore/deprecate-app-container-aliases
Clean up and deprecate app container parameter aliases
2 parents 533e180 + 41b2466 commit e50f4c4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/private/AppFramework/DependencyInjection/DIContainer.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class DIContainer extends SimpleContainer implements IAppContainer {
9696
*/
9797
public function __construct($appName, $urlParams = [], ServerContainer $server = null) {
9898
parent::__construct();
99-
$this['AppName'] = $appName;
99+
$this['appName'] = $appName;
100100
$this['urlParams'] = $urlParams;
101101

102102
$this->registerAlias('Request', IRequest::class);
@@ -109,9 +109,12 @@ public function __construct($appName, $urlParams = [], ServerContainer $server =
109109
$this->server->registerAppContainer($appName, $this);
110110

111111
// aliases
112-
$this->registerAlias('appName', 'AppName');
113-
$this->registerAlias('webRoot', 'WebRoot');
114-
$this->registerAlias('userId', 'UserId');
112+
/** @deprecated inject $appName */
113+
$this->registerAlias('AppName', 'appName');
114+
/** @deprecated inject $webRoot*/
115+
$this->registerAlias('WebRoot', 'webRoot');
116+
/** @deprecated inject $userId */
117+
$this->registerAlias('UserId', 'userId');
115118

116119
/**
117120
* Core services
@@ -158,11 +161,11 @@ public function __construct($appName, $urlParams = [], ServerContainer $server =
158161
$this->registerAlias(IAppContainer::class, ContainerInterface::class);
159162

160163
// commonly used attributes
161-
$this->registerService('UserId', function (ContainerInterface $c) {
164+
$this->registerService('userId', function (ContainerInterface $c) {
162165
return $c->get(IUserSession::class)->getSession()->get('user_id');
163166
});
164167

165-
$this->registerService('WebRoot', function (ContainerInterface $c) {
168+
$this->registerService('webRoot', function (ContainerInterface $c) {
166169
return $c->get(IServerContainer::class)->getWebRoot();
167170
});
168171

0 commit comments

Comments
 (0)