FilterInterface.php 3.3 KB

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