Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\VarDumper\Caster;
|
Chris@0
|
13
|
Chris@0
|
14 use Doctrine\Common\Proxy\Proxy as CommonProxy;
|
Chris@17
|
15 use Doctrine\ORM\PersistentCollection;
|
Chris@0
|
16 use Doctrine\ORM\Proxy\Proxy as OrmProxy;
|
Chris@0
|
17 use Symfony\Component\VarDumper\Cloner\Stub;
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * Casts Doctrine related classes to array representation.
|
Chris@0
|
21 *
|
Chris@0
|
22 * @author Nicolas Grekas <p@tchwork.com>
|
Chris@0
|
23 */
|
Chris@0
|
24 class DoctrineCaster
|
Chris@0
|
25 {
|
Chris@0
|
26 public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, $isNested)
|
Chris@0
|
27 {
|
Chris@17
|
28 foreach (['__cloner__', '__initializer__'] as $k) {
|
Chris@18
|
29 if (\array_key_exists($k, $a)) {
|
Chris@0
|
30 unset($a[$k]);
|
Chris@0
|
31 ++$stub->cut;
|
Chris@0
|
32 }
|
Chris@0
|
33 }
|
Chris@0
|
34
|
Chris@0
|
35 return $a;
|
Chris@0
|
36 }
|
Chris@0
|
37
|
Chris@0
|
38 public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNested)
|
Chris@0
|
39 {
|
Chris@17
|
40 foreach (['_entityPersister', '_identifier'] as $k) {
|
Chris@18
|
41 if (\array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) {
|
Chris@0
|
42 unset($a[$k]);
|
Chris@0
|
43 ++$stub->cut;
|
Chris@0
|
44 }
|
Chris@0
|
45 }
|
Chris@0
|
46
|
Chris@0
|
47 return $a;
|
Chris@0
|
48 }
|
Chris@0
|
49
|
Chris@0
|
50 public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, $isNested)
|
Chris@0
|
51 {
|
Chris@17
|
52 foreach (['snapshot', 'association', 'typeClass'] as $k) {
|
Chris@18
|
53 if (\array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) {
|
Chris@0
|
54 $a[$k] = new CutStub($a[$k]);
|
Chris@0
|
55 }
|
Chris@0
|
56 }
|
Chris@0
|
57
|
Chris@0
|
58 return $a;
|
Chris@0
|
59 }
|
Chris@0
|
60 }
|