AbstractTypeGuesser.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\DoctrineORMAdminBundle\Guesser;
  11. use Sonata\AdminBundle\Guesser\TypeGuesserInterface;
  12. use Doctrine\ORM\Mapping\MappingException;
  13. use Sonata\DoctrineORMAdminBundle\Model\ModelManager;
  14. abstract class AbstractTypeGuesser implements TypeGuesserInterface
  15. {
  16. /**
  17. * @param string $baseClass
  18. * @param string $propertyFullName
  19. * @param \Sonata\DoctrineORMAdminBundle\Model\ModelManager $modelManager
  20. *
  21. * @return array|null
  22. */
  23. protected function getParentMetadataForProperty($baseClass, $propertyFullName, ModelManager $modelManager)
  24. {
  25. try {
  26. return $modelManager->getParentMetadataForProperty($baseClass, $propertyFullName);
  27. } catch (MappingException $e) {
  28. // no metadata not found.
  29. return null;
  30. }
  31. }
  32. }