ConfigureEvent.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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\AdminBundle\Event;
  11. use Sonata\AdminBundle\Admin\AdminInterface;
  12. use Sonata\AdminBundle\Mapper\BaseMapper;
  13. use Symfony\Component\EventDispatcher\Event;
  14. /**
  15. * This event is sent by hook:
  16. * - configureFormFields
  17. * - configureListFields
  18. * - configureDatagridFilters
  19. * - configureShowFields
  20. *
  21. * You can register the listener to the event dispatcher by using:
  22. * - sonata.admin.event.configure.[form|list|datagrid|show]
  23. * - sonata.admin.event.configure.[admin_code].[form|list|datagrid|show] (not implemented yet)
  24. *
  25. */
  26. class ConfigureEvent extends Event
  27. {
  28. const TYPE_SHOW = 'show';
  29. const TYPE_DATAGRID = 'datagrid';
  30. const TYPE_FORM = 'form';
  31. const TYPE_LIST = 'list';
  32. protected $admin;
  33. protected $mapper;
  34. protected $type;
  35. /**
  36. * @param AdminInterface $admin
  37. * @param BaseMapper $mapper
  38. * @param string $type
  39. */
  40. public function __construct(AdminInterface $admin, BaseMapper $mapper, $type)
  41. {
  42. $this->admin = $admin;
  43. $this->mapper = $mapper;
  44. $this->type = $type;
  45. }
  46. /**
  47. * @return mixed
  48. */
  49. public function getType()
  50. {
  51. return $this->type;
  52. }
  53. /**
  54. * @return \Sonata\AdminBundle\Admin\AdminInterface
  55. */
  56. public function getAdmin()
  57. {
  58. return $this->admin;
  59. }
  60. /**
  61. * @return \Sonata\AdminBundle\Mapper\BaseMapper
  62. */
  63. public function getMapper()
  64. {
  65. return $this->mapper;
  66. }
  67. }