diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-11-03 16:55:35 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2022-11-03 16:55:35 +0300 |
commit | 1053dfadf7d91fed32b6784d69857a8f2db35f53 (patch) | |
tree | 730bd6c56a653455ac42308809c8995d1ff5bb66 | |
parent | cd6f419a63e834d6319a3989fc0ae6e56ccc9384 (diff) |
Document deprecation of pascal case DI container parameters
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
3 files changed, 26 insertions, 23 deletions
diff --git a/developer_manual/app_development/tutorial.rst b/developer_manual/app_development/tutorial.rst index 324f4ccde..3d7736c2a 100644 --- a/developer_manual/app_development/tutorial.rst +++ b/developer_manual/app_development/tutorial.rst @@ -107,8 +107,8 @@ This route calls the controller **OCA\\notestutorial\\PageController->index()** class PageController extends Controller { - public function __construct(string $AppName, IRequest $request){ - parent::__construct($AppName, $request); + public function __construct(string $appName, IRequest $request){ + parent::__construct($appName, $request); } /** @@ -133,8 +133,8 @@ Since the route which returns the initial HTML has been taken care of, the contr class NoteController extends Controller { - public function __construct(string $AppName, IRequest $request){ - parent::__construct($AppName, $request); + public function __construct(string $appName, IRequest $request){ + parent::__construct($appName, $request); } /** @@ -386,7 +386,7 @@ Connect database & controllers The mapper which provides the database access is finished and can be passed into the controller. -You can pass in the mapper by adding it as a type hinted parameter. Nextcloud will figure out how to :doc:`assemble them by itself <../basics/dependency_injection>`. Additionally we want to know the userId of the currently logged in user. Simply add a **$UserId** parameter to the constructor (case sensitive!). To do that open **notestutorial/lib/Controller/NoteController.php** and change it to the following: +You can pass in the mapper by adding it as a type hinted parameter. Nextcloud will figure out how to :doc:`assemble them by itself <../basics/dependency_injection>`. Additionally we want to know the userId of the currently logged in user. Simply add a **$userId** parameter to the constructor (case sensitive!). To do that open **notestutorial/lib/Controller/NoteController.php** and change it to the following: .. code-block:: php @@ -408,10 +408,10 @@ You can pass in the mapper by adding it as a type hinted parameter. Nextcloud wi private NoteMapper $mapper; private ?string $userId; - public function __construct(string $AppName, IRequest $request, NoteMapper $mapper, ?string $UserId = null){ - parent::__construct($AppName, $request); + public function __construct(string $appName, IRequest $request, NoteMapper $mapper, ?string $userId = null){ + parent::__construct($appName, $request); $this->mapper = $mapper; - $this->userId = $UserId; + $this->userId = $userId; } /** @@ -654,11 +654,11 @@ Now we can wire up the trait and the service inside the **NoteController**: use Errors; - public function __construct(string $AppName, IRequest $request, - NoteService $service, ?string $UserId = null) { - parent::__construct($AppName, $request); + public function __construct(string $appName, IRequest $request, + NoteService $service, ?string $userId = null) { + parent::__construct($appName, $request); $this->service = $service; - $this->userId = $UserId; + $this->userId = $userId; } /** @@ -967,11 +967,11 @@ With that in mind create a new controller in **notestutorial/lib/Controller/Note use Errors; - public function __construct($AppName, IRequest $request, - NoteService $service, ?string $UserId = null) { - parent::__construct($AppName, $request); + public function __construct(string $appName, IRequest $request, + NoteService $service, ?string $userId = null) { + parent::__construct($appName, $request); $this->service = $service; - $this->userId = $UserId; + $this->userId = $userId; } /** diff --git a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_26.rst b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_26.rst index 45489a601..02b90ae85 100644 --- a/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_26.rst +++ b/developer_manual/app_publishing_maintenance/app_upgrade_guide/upgrade_to_26.rst @@ -33,7 +33,10 @@ tbd Back-end changes ---------------- -tbd +Dependency Injection Parameters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +App container parameters with pascal case names ``AppName``, ``UserId`` and ``WebRoot`` are deprecated. Use the camel case variants ``appName``, ``userId`` and ``webRoot`` instead if you have them injected into one of your app classes. Changed APIs ^^^^^^^^^^^^ diff --git a/developer_manual/basics/dependency_injection.rst b/developer_manual/basics/dependency_injection.rst index 163763210..0dcf04b50 100644 --- a/developer_manual/basics/dependency_injection.rst +++ b/developer_manual/basics/dependency_injection.rst @@ -309,16 +309,16 @@ The following parameter names and type hints can be used to inject core services Parameters: -* **AppName**: The app id -* **UserId**: The id of the current user -* **WebRoot**: The path to the Nextcloud installation +* **appName**: The app id +* **userId**: The id of the current user +* **webRoot**: The path to the Nextcloud installation Aliases: -* **appName**: resolves to ``AppName`` +* **AppName**: resolves to ``AppName`` (deprecated) * **Request**: resolves to ``\OCP\\IRequest`` * **ServerContainer**: resolves to ``\OCP\IServerContainer`` -* **userId**: resolves to ``UserId`` -* **webRoot**: resolves to ``WebRoot`` +* **UserId**: resolves to ``UserId`` (deprecated) +* **WebRoot**: resolves to ``WebRoot`` (deprecated) Types: |