diff --git a/Table/Filter/AbstractFilter.php b/Table/Filter/AbstractFilter.php index 5c53dbd..618844f 100644 --- a/Table/Filter/AbstractFilter.php +++ b/Table/Filter/AbstractFilter.php @@ -129,6 +129,17 @@ abstract class AbstractFilter implements FilterInterface * @var ValueManipulatorInterface */ protected $valueManipulator; + + /** + * Value of Mapped. + * + * If you wish the filter to be ignored + * when the queryBuilder will be created set + * the mapped option to false. + * + * @var bool + */ + protected $mapped; public function __construct(ContainerInterface $container) { @@ -201,6 +212,12 @@ public function getOperator() return $this->operator; } + + public function getMapped() + { + return $this->mapped; + } + /** * * @return mixed Value of this filter or default value, @@ -280,6 +297,7 @@ public function setOptions(array $options) $this->labelAttributes = $this->options['label_attr']; $this->defaultValue = $this->options['default_value']; $this->valueManipulator = $this->options['value_manipulator']; + $this->mapped = $this->options['mapped']; FilterOperator::validate($this->operator); } @@ -298,7 +316,8 @@ protected function setDefaultFilterOptions(OptionsResolver $optionsResolver) 'attr' => array(), 'label_attr' => array('styles' => 'font-weight: bold'), 'default_value' => null, - 'value_manipulator' => null + 'value_manipulator' => null, + 'mapped' => true )); } @@ -372,6 +391,10 @@ protected function getAllFilterExpressions() public function isActive() { + if ($this->mapped === false) { + return false; + } + return isset($this->value) && strlen($this->value) > 0; } } diff --git a/Table/Filter/FilterInterface.php b/Table/Filter/FilterInterface.php index f06b2a5..49be0a7 100644 --- a/Table/Filter/FilterInterface.php +++ b/Table/Filter/FilterInterface.php @@ -103,6 +103,12 @@ public function getValue($mode = FilterInterface::FOR_FILTERING); */ public function getWidgetBlockName(); + + /** + * @return bool Mapped value. + */ + public function getMapped(); + /** * Returns True, if the filter is active. *