ConfigureEvent.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. protected $admin;
  34. protected $mapper;
  35. protected $type;
  36. /**
  37. * @param AdminInterface $admin
  38. * @param BaseMapper $mapper
  39. * @param string $type
  40. */
  41. public function __construct(AdminInterface $admin, BaseMapper $mapper, $type)
  42. {
  43. $this->admin = $admin;
  44. $this->mapper = $mapper;
  45. $this->type = $type;
  46. }
  47. /**
  48. * @return mixed
  49. */
  50. public function getType()
  51. {
  52. return $this->type;
  53. }
  54. /**
  55. * @return \Sonata\AdminBundle\Admin\AdminInterface
  56. */
  57. public function getAdmin()
  58. {
  59. return $this->admin;
  60. }
  61. /**
  62. * @return \Sonata\AdminBundle\Mapper\BaseMapper
  63. */
  64. public function getMapper()
  65. {
  66. return $this->mapper;
  67. }
  68. }