ConfigureQueryEvent.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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\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. */
  23. class ConfigureQueryEvent extends Event
  24. {
  25. protected $admin;
  26. protected $proxyQuery;
  27. protected $context;
  28. /**
  29. * @param AdminInterface $admin
  30. * @param ProxyQueryInterface $proxyQuery
  31. * @param string $context
  32. */
  33. public function __construct(AdminInterface $admin, ProxyQueryInterface $proxyQuery, $context)
  34. {
  35. $this->admin = $admin;
  36. $this->proxyQuery = $proxyQuery;
  37. $this->context = $context;
  38. }
  39. /**
  40. * @return AdminInterface
  41. */
  42. public function getAdmin()
  43. {
  44. return $this->admin;
  45. }
  46. /**
  47. * @return string
  48. */
  49. public function getContext()
  50. {
  51. return $this->context;
  52. }
  53. /**
  54. * @return ProxyQueryInterface
  55. */
  56. public function getProxyQuery()
  57. {
  58. return $this->proxyQuery;
  59. }
  60. }