diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-08-16 08:22:05 +0200 |
commit | 1a365e77dfb8825136626202b1df462731b42060 (patch) | |
tree | 1dc4468eaabf070e051e790a9e67a9a9a2c63d99 /vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php | |
parent | a72fd280f7acb4d2a1ba579a0f1b2b2ae8958530 (diff) |
Update to MediaWiki 1.25.2
Diffstat (limited to 'vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php')
-rw-r--r-- | vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php new file mode 100644 index 00000000..665f155f --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractFilter.php @@ -0,0 +1,57 @@ +<?php + +namespace Elastica\Filter; + +use Elastica\Exception\InvalidException; +use Elastica\Param; + +/** + * Abstract filter object. Should be extended by all filter types + * + * @category Xodoa + * @package Elastica + * @author Nicolas Ruflin <spam@ruflin.com> + * @link http://www.elasticsearch.org/guide/reference/query-dsl/ + */ +abstract class AbstractFilter extends Param +{ + /** + * Sets the filter cache + * + * @param boolean $cached Cached + * @return \Elastica\Filter\AbstractFilter + */ + public function setCached($cached = true) + { + return $this->setParam('_cache', (bool) $cached); + } + + /** + * Sets the filter cache key + * + * @param string $cacheKey Cache key + * @throws \Elastica\Exception\InvalidException + * @return \Elastica\Filter\AbstractFilter + */ + public function setCacheKey($cacheKey) + { + $cacheKey = (string) $cacheKey; + + if (empty($cacheKey)) { + throw new InvalidException('Invalid parameter. Has to be a non empty string'); + } + + return $this->setParam('_cache_key', (string) $cacheKey); + } + + /** + * Sets the filter name + * + * @param string $name Name + * @return \Elastica\Filter\AbstractFilter + */ + public function setName($name) + { + return $this->setParam('_name', $name); + } +} |