FilterInterface.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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\Filter;
  11. use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  12. interface FilterInterface
  13. {
  14. const CONDITION_OR = 'OR';
  15. const CONDITION_AND = 'AND';
  16. /**
  17. * Apply the filter to the QueryBuilder instance
  18. *
  19. * @param ProxyQueryInterface $queryBuilder
  20. * @param string $alias
  21. * @param string $field
  22. * @param string $value
  23. *
  24. * @return void
  25. */
  26. public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value);
  27. /**
  28. * @param mixed $query
  29. * @param mixed $value
  30. */
  31. public function apply($query, $value);
  32. /**
  33. * Returns the filter name
  34. *
  35. * @return string
  36. */
  37. public function getName();
  38. /**
  39. * Returns the filter form name
  40. *
  41. * @return string
  42. */
  43. public function getFormName();
  44. /**
  45. * Returns the label name
  46. *
  47. * @return string|bool
  48. */
  49. public function getLabel();
  50. /**
  51. * @param string $label
  52. */
  53. public function setLabel($label);
  54. /**
  55. * @return array
  56. */
  57. public function getDefaultOptions();
  58. /**
  59. * @param string $name
  60. * @param null $default
  61. *
  62. * @return mixed
  63. */
  64. public function getOption($name, $default = null);
  65. /**
  66. * @param string $name
  67. * @param mixed $value
  68. */
  69. public function setOption($name, $value);
  70. /**
  71. * @param string $name
  72. * @param array $options
  73. *
  74. * @return void
  75. */
  76. public function initialize($name, array $options = array());
  77. /**
  78. * @return string
  79. */
  80. public function getFieldName();
  81. /**
  82. * @return array of mappings
  83. */
  84. public function getParentAssociationMappings();
  85. /**
  86. * @return array field mapping
  87. */
  88. public function getFieldMapping();
  89. /**
  90. * @return array association mapping
  91. */
  92. public function getAssociationMapping();
  93. /**
  94. * @return array
  95. */
  96. public function getFieldOptions();
  97. /**
  98. * Get field option
  99. *
  100. * @return mixed
  101. */
  102. public function getFieldOption($name, $default = null);
  103. /**
  104. * Set field option
  105. *
  106. * @param string $name
  107. * @param mixed $value
  108. */
  109. public function setFieldOption($name, $value);
  110. /**
  111. * @return string
  112. */
  113. public function getFieldType();
  114. /**
  115. * Returns the main widget used to render the filter
  116. *
  117. * @return array
  118. */
  119. public function getRenderSettings();
  120. /**
  121. * Returns true if filter is active
  122. *
  123. * @return boolean
  124. */
  125. public function isActive();
  126. /**
  127. * Set the condition to use with the left side of the query : OR or AND
  128. *
  129. * @param string $condition
  130. */
  131. public function setCondition($condition);
  132. /**
  133. * @return string
  134. */
  135. public function getCondition();
  136. /**
  137. * @return string
  138. */
  139. public function getTranslationDomain();
  140. }