FilterInterface.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. 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. public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value);
  25. /**
  26. * @param mixed $query
  27. * @param mixed $value
  28. */
  29. public function apply($query, $value);
  30. /**
  31. * Returns the filter name.
  32. *
  33. * @return string
  34. */
  35. public function getName();
  36. /**
  37. * Returns the filter form name.
  38. *
  39. * @return string
  40. */
  41. public function getFormName();
  42. /**
  43. * Returns the label name.
  44. *
  45. * @return string|bool
  46. */
  47. public function getLabel();
  48. /**
  49. * @param string $label
  50. */
  51. public function setLabel($label);
  52. /**
  53. * @return array
  54. */
  55. public function getDefaultOptions();
  56. /**
  57. * @param string $name
  58. * @param null $default
  59. *
  60. * @return mixed
  61. */
  62. public function getOption($name, $default = null);
  63. /**
  64. * @param string $name
  65. * @param mixed $value
  66. */
  67. public function setOption($name, $value);
  68. /**
  69. * @param string $name
  70. * @param array $options
  71. */
  72. public function initialize($name, array $options = array());
  73. /**
  74. * @return string
  75. */
  76. public function getFieldName();
  77. /**
  78. * @return array of mappings
  79. */
  80. public function getParentAssociationMappings();
  81. /**
  82. * @return array field mapping
  83. */
  84. public function getFieldMapping();
  85. /**
  86. * @return array association mapping
  87. */
  88. public function getAssociationMapping();
  89. /**
  90. * @return array
  91. */
  92. public function getFieldOptions();
  93. /**
  94. * @return string
  95. */
  96. public function getFieldType();
  97. /**
  98. * Returns the main widget used to render the filter.
  99. *
  100. * @return array
  101. */
  102. public function getRenderSettings();
  103. /**
  104. * Returns true if filter is active.
  105. *
  106. * @return bool
  107. */
  108. public function isActive();
  109. /**
  110. * Set the condition to use with the left side of the query : OR or AND.
  111. *
  112. * @param string $condition
  113. */
  114. public function setCondition($condition);
  115. /**
  116. * @return string
  117. */
  118. public function getCondition();
  119. /**
  120. * @return string
  121. */
  122. public function getTranslationDomain();
  123. }