Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of the Symfony package.
5
 *
6
 * (c) Fabien Potencier <fabien@symfony.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
 
12
namespace Symfony\Component\VarDumper\Dumper;
13
 
14
use Symfony\Component\VarDumper\Cloner\Data;
15
use Symfony\Component\VarDumper\Dumper\ContextProvider\ContextProviderInterface;
16
 
17
/**
18
 * @author Kévin Thérage <therage.kevin@gmail.com>
19
 */
20
class ContextualizedDumper implements DataDumperInterface
21
{
22
    private DataDumperInterface $wrappedDumper;
23
    private array $contextProviders;
24
 
25
    /**
26
     * @param ContextProviderInterface[] $contextProviders
27
     */
28
    public function __construct(DataDumperInterface $wrappedDumper, array $contextProviders)
29
    {
30
        $this->wrappedDumper = $wrappedDumper;
31
        $this->contextProviders = $contextProviders;
32
    }
33
 
34
    public function dump(Data $data)
35
    {
36
        $context = [];
37
        foreach ($this->contextProviders as $contextProvider) {
38
            $context[$contextProvider::class] = $contextProvider->getContext();
39
        }
40
 
41
        $this->wrappedDumper->dump($data->withContext($context));
42
    }
43
}