Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Spatie\LaravelIgnition\Exceptions;
4
 
5
use ErrorException;
6
use Spatie\FlareClient\Contracts\ProvidesFlareContext;
7
use Spatie\LaravelIgnition\Recorders\DumpRecorder\HtmlDumper;
8
 
9
class ViewException extends ErrorException implements ProvidesFlareContext
10
{
11
    /** @var array<string, mixed> */
12
    protected array $viewData = [];
13
 
14
    protected string $view = '';
15
 
16
    /**
17
     * @param array<string, mixed> $data
18
     *
19
     * @return void
20
     */
21
    public function setViewData(array $data): void
22
    {
23
        $this->viewData = $data;
24
    }
25
 
26
    /** @return array<string, mixed> */
27
    public function getViewData(): array
28
    {
29
        return $this->viewData;
30
    }
31
 
32
    public function setView(string $path): void
33
    {
34
        $this->view = $path;
35
    }
36
 
37
    protected function dumpViewData(mixed $variable): string
38
    {
39
        return (new HtmlDumper())->dumpVariable($variable);
40
    }
41
 
42
    /** @return array<string, mixed> */
43
    public function context(): array
44
    {
45
        $context = [
46
            'view' => [
47
                'view' => $this->view,
48
            ],
49
        ];
50
 
51
        $context['view']['data'] = array_map([$this, 'dumpViewData'], $this->viewData);
52
 
53
        return $context;
54
    }
55
}