mirror of
https://github.com/nextcloud/documentation.git
synced 2026-01-03 02:09:45 +07:00
Document deprecation of pascal case DI container parameters
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
^^^^^^^^^^^^
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user