説明なし

DoctrineCaster.php 1.5KB

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