public function getSolution(): ?string
{
$solution = [
<<<SOLUTION
## Got definition value
`{$this->definitionString}`
SOLUTION
];
$suggestion = $this->generateSuggestion();
if ($suggestion !== null) {
$solution[] = '## Suggestion';
$solution[] = $suggestion;
}
$solution[] = <<<SOLUTION
## Middleware definition examples
PSR middleware class name:
```php
Yiisoft\Session\SessionMiddleware::class
```
PSR request handler class name:
```php
Yiisoft\Yii\Swagger\Action\SwaggerUi::class
```
An identifier of container definition for PSR middleware:
```php
'sessionMiddleware'
```
where `sessionMiddleware` is the identifier of container definition for `Yiisoft\Session\SessionMiddleware`.
PSR middleware array definition:
```php
[
'class' => MyMiddleware::class,
'__construct()' => [
'someVar' => 42,
],
]
```
Closure that returns `ResponseInterface`:
```php
static function (): ResponseInterface {
return new Response(418);
},
```
Closure that returns `MiddlewareInterface`:
```php
static function (): MiddlewareInterface {
return new TestMiddleware();
}
```
Closure that returns `RequestHandlerInterface`:
```php
static function (): RequestHandlerInterface {
return new SimpleRequestHandler();
}
```
Action in controller:
```php
[App\Backend\UserController::class, 'index']
```
## Related links
- [Array definition syntax](https://github.com/yiisoft/definitions#arraydefinition)
- [Callable PHP documentation](https://www.php.net/manual/language.types.callable.php)
SOLUTION;
return implode("\n\n", $solution);
}
Signup or Login in order to comment.