FilterInterface.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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
  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. * @return string
  99. */
  100. public function getFieldType();
  101. /**
  102. * Returns the main widget used to render the filter
  103. *
  104. * @return array
  105. */
  106. public function getRenderSettings();
  107. /**
  108. * Returns true if filter is active
  109. *
  110. * @return boolean
  111. */
  112. public function isActive();
  113. /**
  114. * Set the condition to use with the left side of the query : OR or AND
  115. *
  116. * @param string $condition
  117. */
  118. public function setCondition($condition);
  119. /**
  120. * @return string
  121. */
  122. public function getCondition();
  123. /**
  124. * @return string
  125. */
  126. public function getTranslationDomain();
  127. }