ConfigureQueryEvent.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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\Datagrid\ProxyQueryInterface;
  13. use Symfony\Component\EventDispatcher\Event;
  14. /**
  15. * This event is sent by hook:
  16. * - configureQuery.
  17. *
  18. * You can register the listener to the event dispatcher by using:
  19. * - sonata.admin.event.configure.query
  20. * - sonata.admin.event.configure.[admin_code].query (not implemented yet)
  21. *
  22. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  23. */
  24. class ConfigureQueryEvent extends Event
  25. {
  26. /**
  27. * @var AdminInterface
  28. */
  29. protected $admin;
  30. /**
  31. * @var ProxyQueryInterface
  32. */
  33. protected $proxyQuery;
  34. /**
  35. * @var string
  36. */
  37. protected $context;
  38. /**
  39. * @param AdminInterface $admin
  40. * @param ProxyQueryInterface $proxyQuery
  41. * @param string $context
  42. */
  43. public function __construct(AdminInterface $admin, ProxyQueryInterface $proxyQuery, $context)
  44. {
  45. $this->admin = $admin;
  46. $this->proxyQuery = $proxyQuery;
  47. $this->context = $context;
  48. }
  49. /**
  50. * @return AdminInterface
  51. */
  52. public function getAdmin()
  53. {
  54. return $this->admin;
  55. }
  56. /**
  57. * @return string
  58. */
  59. public function getContext()
  60. {
  61. return $this->context;
  62. }
  63. /**
  64. * @return ProxyQueryInterface
  65. */
  66. public function getProxyQuery()
  67. {
  68. return $this->proxyQuery;
  69. }
  70. }