Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion Table/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}

Expand All @@ -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
));
}

Expand Down Expand Up @@ -372,6 +391,10 @@ protected function getAllFilterExpressions()

public function isActive()
{
if ($this->mapped === false) {
return false;
}

return isset($this->value) && strlen($this->value) > 0;
}
}
6 changes: 6 additions & 0 deletions Table/Filter/FilterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down