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
use Symfony\Component\VarDumper\Server\Connection;
17
 
18
/**
19
 * ServerDumper forwards serialized Data clones to a server.
20
 *
21
 * @author Maxime Steinhausser <maxime.steinhausser@gmail.com>
22
 */
23
class ServerDumper implements DataDumperInterface
24
{
25
    private Connection $connection;
26
    private ?DataDumperInterface $wrappedDumper;
27
 
28
    /**
29
     * @param string                     $host             The server host
30
     * @param DataDumperInterface|null   $wrappedDumper    A wrapped instance used whenever we failed contacting the server
31
     * @param ContextProviderInterface[] $contextProviders Context providers indexed by context name
32
     */
33
    public function __construct(string $host, DataDumperInterface $wrappedDumper = null, array $contextProviders = [])
34
    {
35
        $this->connection = new Connection($host, $contextProviders);
36
        $this->wrappedDumper = $wrappedDumper;
37
    }
38
 
39
    public function getContextProviders(): array
40
    {
41
        return $this->connection->getContextProviders();
42
    }
43
 
44
    public function dump(Data $data)
45
    {
46
        if (!$this->connection->write($data) && $this->wrappedDumper) {
47
            $this->wrappedDumper->dump($data);
48
        }
49
    }
50
}