Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\VarDumper\Caster; Chris@0: Chris@0: use Doctrine\Common\Proxy\Proxy as CommonProxy; Chris@0: use Doctrine\ORM\Proxy\Proxy as OrmProxy; Chris@0: use Doctrine\ORM\PersistentCollection; Chris@0: use Symfony\Component\VarDumper\Cloner\Stub; Chris@0: Chris@0: /** Chris@0: * Casts Doctrine related classes to array representation. Chris@0: * Chris@0: * @author Nicolas Grekas Chris@0: */ Chris@0: class DoctrineCaster Chris@0: { Chris@0: public static function castCommonProxy(CommonProxy $proxy, array $a, Stub $stub, $isNested) Chris@0: { Chris@0: foreach (array('__cloner__', '__initializer__') as $k) { Chris@0: if (array_key_exists($k, $a)) { Chris@0: unset($a[$k]); Chris@0: ++$stub->cut; Chris@0: } Chris@0: } Chris@0: Chris@0: return $a; Chris@0: } Chris@0: Chris@0: public static function castOrmProxy(OrmProxy $proxy, array $a, Stub $stub, $isNested) Chris@0: { Chris@0: foreach (array('_entityPersister', '_identifier') as $k) { Chris@0: if (array_key_exists($k = "\0Doctrine\\ORM\\Proxy\\Proxy\0".$k, $a)) { Chris@0: unset($a[$k]); Chris@0: ++$stub->cut; Chris@0: } Chris@0: } Chris@0: Chris@0: return $a; Chris@0: } Chris@0: Chris@0: public static function castPersistentCollection(PersistentCollection $coll, array $a, Stub $stub, $isNested) Chris@0: { Chris@0: foreach (array('snapshot', 'association', 'typeClass') as $k) { Chris@0: if (array_key_exists($k = "\0Doctrine\\ORM\\PersistentCollection\0".$k, $a)) { Chris@0: $a[$k] = new CutStub($a[$k]); Chris@0: } Chris@0: } Chris@0: Chris@0: return $a; Chris@0: } Chris@0: }