Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c426d8b

Browse filesBrowse files
[VarDumper] casters for Doctrine objects
1 parent 0a92c08 commit c426d8b
Copy full SHA for c426d8b

File tree

Expand file treeCollapse file tree

2 files changed

+78
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+78
-0
lines changed
+73Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
}

‎src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Cloner/AbstractCloner.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ abstract class AbstractCloner implements ClonerInterface
2424
'o:Closure' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castClosure',
2525
'o:Reflector' => 'Symfony\Component\VarDumper\Caster\ReflectionCaster::castReflector',
2626

27+
'o:Doctrine\Common\Persistence\ObjectManager' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castObjectManager',
28+
'o:Doctrine\Common\Proxy\Proxy' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castCommonProxy',
29+
'o:Doctrine\ORM\Proxy\Proxy' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castOrmProxy',
30+
'o:Doctrine\ORM\PersistentCollection' => 'Symfony\Component\VarDumper\Caster\DoctrineCaster::castPersistentCollection',
31+
2732
'o:ErrorException' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castErrorException',
2833
'o:Exception' => 'Symfony\Component\VarDumper\Caster\ExceptionCaster::castException',
2934
'o:Symfony\Component\VarDumper\Exception\ThrowingCasterException'

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.