FilterInterface.php 3.3 KB

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