|
| 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\Caster; |
| 13 | + |
| 14 | +use Doctrine\Common\Persistence\ObjectManager; |
| 15 | +use Doctrine\Common\Proxy\Proxy as CommonProxy; |
| 16 | +use Doctrine\ORM\Proxy\Proxy as OrmProxy; |
| 17 | +use Doctrine\ORM\PersistentCollection; |
| 18 | + |
| 19 | +/** |
| 20 | + * Casts Doctrine related classes to array representation. |
| 21 | + * |
| 22 | + * @author Nicolas Grekas <p@tchwork.com> |
| 23 | + */ |
| 24 | +class DoctrineCaster |
| 25 | +{ |
| 26 | + public static function castCommonProxy(CommonProxy $proxy, array $a, $isNested, &$cut) |
| 27 | + { |
| 28 | + unset( |
| 29 | + $a['__cloner__'], |
| 30 | + $a['__initializer__'] |
| 31 | + ); |
| 32 | + $cut += 2; |
| 33 | + |
| 34 | + return $a; |
| 35 | + } |
| 36 | + |
| 37 | + public static function castOrmProxy(OrmProxy $proxy, array $a, $isNested, &$cut) |
| 38 | + { |
| 39 | + $prefix = "\0Doctrine\\ORM\\Proxy\\Proxy\0"; |
| 40 | + unset( |
| 41 | + $a[$prefix.'_entityPersister'], |
| 42 | + $a[$prefix.'_identifier'] |
| 43 | + ); |
| 44 | + $cut += 2; |
| 45 | + |
| 46 | + return $a; |
| 47 | + } |
| 48 | + |
| 49 | + public static function castObjectManager(ObjectManager $manager, array $a, $isNested, &$cut) |
| 50 | + { |
| 51 | + if ($isNested) { |
| 52 | + $cut += count($a); |
| 53 | + |
| 54 | + return array(); |
| 55 | + } |
| 56 | + |
| 57 | + return $a; |
| 58 | + } |
| 59 | + |
| 60 | + public static function castPersistentCollection(PersistentCollection $coll, array $a, $isNested, &$cut) |
| 61 | + { |
| 62 | + $prefix = "\0Doctrine\\ORM\\PersistentCollection\0"; |
| 63 | + unset( |
| 64 | + $a[$prefix.'snapshot'], |
| 65 | + $a[$prefix.'association'], |
| 66 | + $a[$prefix.'em'], |
| 67 | + $a[$prefix.'typeClass'] |
| 68 | + ); |
| 69 | + $cut += 4; |
| 70 | + |
| 71 | + return $a; |
| 72 | + } |
| 73 | +} |
0 commit comments