| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Spatie\FlareClient\FlareMiddleware;
|
|
|
4 |
|
|
|
5 |
use Closure;
|
|
|
6 |
use Spatie\FlareClient\Report;
|
|
|
7 |
use Spatie\Ignition\Contracts\SolutionProviderRepository;
|
|
|
8 |
|
|
|
9 |
class AddSolutions implements FlareMiddleware
|
|
|
10 |
{
|
|
|
11 |
protected SolutionProviderRepository $solutionProviderRepository;
|
|
|
12 |
|
|
|
13 |
public function __construct(SolutionProviderRepository $solutionProviderRepository)
|
|
|
14 |
{
|
|
|
15 |
$this->solutionProviderRepository = $solutionProviderRepository;
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
public function handle(Report $report, Closure $next)
|
|
|
19 |
{
|
|
|
20 |
if ($throwable = $report->getThrowable()) {
|
|
|
21 |
$solutions = $this->solutionProviderRepository->getSolutionsForThrowable($throwable);
|
|
|
22 |
|
|
|
23 |
foreach ($solutions as $solution) {
|
|
|
24 |
$report->addSolution($solution);
|
|
|
25 |
}
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
return $next($report);
|
|
|
29 |
}
|
|
|
30 |
}
|