Skip to content

Commit 85ec4f0

Browse files
committed
Move providers to config
1 parent f09026b commit 85ec4f0

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"source-directory": "config"
7474
},
7575
"config-plugin": {
76-
"di-web": "di-web.php"
76+
"di-web": "di-web.php",
77+
"params": "params.php"
7778
}
7879
},
7980
"config": {

config/di-web.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,9 @@
1111

1212
return [
1313
ThrowableRendererInterface::class => HtmlRenderer::class,
14+
HtmlRenderer::class => [
15+
'__construct()' => [
16+
'solutionProviders' => $params['yiisoft/error-handler']['solutionProviders'],
17+
],
18+
],
1419
];

config/params.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Yiisoft\ErrorHandler\Renderer\HtmlRenderer;
6+
use Yiisoft\ErrorHandler\ThrowableRendererInterface;
7+
8+
/**
9+
* @var array $params
10+
*/
11+
12+
return [
13+
'yiisoft/error-handler' => [
14+
'solutionProviders' => [
15+
\Yiisoft\Definitions\Reference::to(\Yiisoft\ErrorHandler\Solution\FriendlyExceptionSolution::class),
16+
]
17+
]
18+
];

src/Renderer/HtmlRenderer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use Yiisoft\ErrorHandler\ErrorData;
1414
use Yiisoft\ErrorHandler\Exception\ErrorException;
1515
use Yiisoft\ErrorHandler\Solution\SolutionGenerator;
16-
use Yiisoft\ErrorHandler\Solution\FriendlyExceptionSolution;
1716
use Yiisoft\ErrorHandler\ThrowableRendererInterface;
1817
use Yiisoft\FriendlyException\FriendlyExceptionInterface;
1918

@@ -123,8 +122,9 @@ final class HtmlRenderer implements ThrowableRendererInterface
123122
* maxTraceLines?: int,
124123
* traceHeaderLine?: string,
125124
* } $settings
125+
* @param \Yiisoft\ErrorHandler\Solution\SolutionProviderInterface[] $solutionProviders
126126
*/
127-
public function __construct(array $settings = [])
127+
public function __construct(array $settings = [], array $solutionProviders = [])
128128
{
129129
$this->markdownParser = new GithubMarkdown();
130130
$this->markdownParser->html5 = true;
@@ -135,7 +135,7 @@ public function __construct(array $settings = [])
135135
$this->maxSourceLines = $settings['maxSourceLines'] ?? 19;
136136
$this->maxTraceLines = $settings['maxTraceLines'] ?? 13;
137137
$this->traceHeaderLine = $settings['traceHeaderLine'] ?? null;
138-
$this->solutionGenerator = new SolutionGenerator([new FriendlyExceptionSolution()]);
138+
$this->solutionGenerator = new SolutionGenerator($solutionProviders);
139139
}
140140

141141
public function render(Throwable $t, ServerRequestInterface $request = null): ErrorData

0 commit comments

Comments
 (0)