ConfigureQueryEvent.php 1.6 KB

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