ConfigureEvent.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  26. */
  27. class ConfigureEvent extends Event
  28. {
  29. const TYPE_SHOW = 'show';
  30. const TYPE_DATAGRID = 'datagrid';
  31. const TYPE_FORM = 'form';
  32. const TYPE_LIST = 'list';
  33. /**
  34. * @var AdminInterface
  35. */
  36. protected $admin;
  37. /**
  38. * @var BaseMapper
  39. */
  40. protected $mapper;
  41. /**
  42. * @var string
  43. */
  44. protected $type;
  45. /**
  46. * @param AdminInterface $admin
  47. * @param BaseMapper $mapper
  48. * @param string $type
  49. */
  50. public function __construct(AdminInterface $admin, BaseMapper $mapper, $type)
  51. {
  52. $this->admin = $admin;
  53. $this->mapper = $mapper;
  54. $this->type = $type;
  55. }
  56. /**
  57. * @return mixed
  58. */
  59. public function getType()
  60. {
  61. return $this->type;
  62. }
  63. /**
  64. * @return AdminInterface
  65. */
  66. public function getAdmin()
  67. {
  68. return $this->admin;
  69. }
  70. /**
  71. * @return BaseMapper
  72. */
  73. public function getMapper()
  74. {
  75. return $this->mapper;
  76. }
  77. }