EntityAdmin.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\BaseApplicationBundle\Admin;
  11. abstract class EntityAdmin extends Admin
  12. {
  13. /**
  14. * return the entity manager
  15. *
  16. * @return EntityManager
  17. */
  18. public function getEntityManager()
  19. {
  20. return $this->container->get('doctrine.orm.default_entity_manager');
  21. }
  22. /**
  23. * return the doctrine class metadata handled by the Admin instance
  24. *
  25. * @return ClassMetadataInfo the doctrine class metadata handled by the Admin instance
  26. */
  27. public function getClassMetaData()
  28. {
  29. return $this->getEntityManager()
  30. ->getClassMetaData($this->getClass());
  31. }
  32. /**
  33. * return the FormBuilder
  34. *
  35. * @return FormBuilder
  36. */
  37. public function getFormBuilder()
  38. {
  39. return $this->container->get('sonata_base_application.builder.orm_form');
  40. }
  41. /**
  42. * return the ListBuilder
  43. *
  44. * @return ListBuilder
  45. */
  46. public function getListBuilder()
  47. {
  48. return $this->container->get('sonata_base_application.builder.orm_list');
  49. }
  50. /**
  51. * return the DatagridBuilder
  52. *
  53. * @return DatagridBuilder
  54. */
  55. public function getDatagridBuilder()
  56. {
  57. return $this->container->get('sonata_base_application.builder.orm_datagrid');
  58. }
  59. }