ConfigureEvent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project 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. class ConfigureEvent extends Event
  26. {
  27. const TYPE_SHOW = 'show';
  28. const TYPE_DATAGRID = 'datagrid';
  29. const TYPE_FORM = 'form';
  30. const TYPE_LIST = 'list';
  31. protected $admin;
  32. protected $mapper;
  33. protected $type;
  34. /**
  35. * @param AdminInterface $admin
  36. * @param BaseMapper $mapper
  37. * @param string $type
  38. */
  39. public function __construct(AdminInterface $admin, BaseMapper $mapper, $type)
  40. {
  41. $this->admin = $admin;
  42. $this->mapper = $mapper;
  43. $this->type = $type;
  44. }
  45. /**
  46. * @return mixed
  47. */
  48. public function getType()
  49. {
  50. return $this->type;
  51. }
  52. /**
  53. * @return \Sonata\AdminBundle\Admin\AdminInterface
  54. */
  55. public function getAdmin()
  56. {
  57. return $this->admin;
  58. }
  59. /**
  60. * @return \Sonata\AdminBundle\Mapper\BaseMapper
  61. */
  62. public function getMapper()
  63. {
  64. return $this->mapper;
  65. }
  66. }