silverstripe-framework/search/filters/SubstringFilter.php
Simon Welsh c49f7566c3 API Allow use of :not, :nocase and :case modifiers to SearchFilters.
More modifiers can be added to each class as desired.
2012-10-10 10:26:47 +13:00

45 lines
1.1 KiB
PHP
Executable File

<?php
/**
* @package framework
* @subpackage search
*/
/**
* Uses a substring match against content in column rows.
* @deprecated 3.0 Use PartialMatchFilter instead
*
* @package framework
* @subpackage search
*/
class SubstringFilter extends PartialMatchFilter {
public function __construct($fullName, $value = false, array $modifiers = array()) {
Deprecation::notice('3.0', 'PartialMatchFilter instead.');
parent::__construct($fullName, $value, $modifiers);
}
public function apply(DataQuery $query) {
$values = $this->getValue();
$filter = new PartialMatchFilter($this->getFullName(), $values, $this->getModifiers());
return $filter->apply($query);
}
protected function applyOne(DataQuery $query) {
/* NO OP */
}
public function exclude(DataQuery $query) {
$values = $this->getValue();
$filter = new PartialMatchFilter($this->getFullName(), $values, $this->getModifiers());
return $filter->exclude($query);
}
protected function excludeOne(DataQuery $query) {
/* NO OP */
}
public function isEmpty() {
return $this->getValue() === array() || $this->getValue() === null || $this->getValue() === '';
}
}