/** * Add a new filter to this input value * * @param string $path * @param FilterInterface $filter * @return FilterContainerInterface */ public function addFilter(string $path, FilterInterface $filter) : FilterContainerInterface { if (!isset($this->filterMap[$path])) { $this->filterMap[$path] = []; } $this->filterMap[$path][] = $filter->setIndex($path); return $this; }
public function filter($name, $value) { if (is_array($value)) { foreach ($value as &$arrayValue) { $arrayValue = $this->filter->filter($name, $arrayValue); } return $value; } else { return $this->filter->filter($name, $value); } }
/** * Filter the array * * @param FilterInterface $filter Filter to use * * @return \ArrayObject */ public function filterBy(FilterInterface $filter) { $arrayToFilter = $this->arrayToFilter; $filteredArray = new \ArrayObject(); foreach ($arrayToFilter as $key => $value) { if ($filter->isSatisfiedBy($key, $value)) { $filteredArray->offsetSet($key, $value); } } return $filteredArray; }
/** * Allow for filter chaining * * @param string $method The function name * @param array $arguments The function arguments * @return mixed The result of the function * @throws \BadMethodCallException If method could not be found */ public function __call($method, $arguments) { //Call the method on the filter if it exists if ($this->_last instanceof FilterInterface) { $methods = $this->_last->getMethods(); if (isset($methods[$method])) { call_user_func_array(array($this->_last, $method), $arguments); return $this; } } //Create a new filter based on the method name $filter = $this->getObject('filter.factory')->createFilter($method, $arguments); $this->addFilter($filter); return $this; }
/** * Asserts multiple filter output expectations for multiple input strings. * * @param FilterInterface $filter * A input filter object. * @param $tests * An associative array, whereas each key is an arbitrary input string and * each value is again an associative array whose keys are filter output * strings and whose values are Booleans indicating whether the output is * expected or not. * * For example: * @code * $tests = array( * 'Input string' => array( * '<p>Input string</p>' => TRUE, * 'Input string<br' => FALSE, * ), * ); * @endcode */ function assertFilteredString($filter, $tests) { foreach ($tests as $source => $tasks) { $result = $filter->process($source, $filter)->getProcessedText(); foreach ($tasks as $value => $is_expected) { // Not using assertIdentical, since combination with strpos() is hard to grok. if ($is_expected) { $success = $this->assertTrue(strpos($result, $value) !== FALSE, format_string('@source: @value found. Filtered result: @result.', array('@source' => var_export($source, TRUE), '@value' => var_export($value, TRUE), '@result' => var_export($result, TRUE)))); } else { $success = $this->assertTrue(strpos($result, $value) === FALSE, format_string('@source: @value not found. Filtered result: @result.', array('@source' => var_export($source, TRUE), '@value' => var_export($value, TRUE), '@result' => var_export($result, TRUE)))); } if (!$success) { $this->verbose('Source:<pre>' . Html::escape(var_export($source, TRUE)) . '</pre>' . '<hr />' . 'Result:<pre>' . Html::escape(var_export($result, TRUE)) . '</pre>' . '<hr />' . ($is_expected ? 'Expected:' : 'Not expected:') . '<pre>' . Html::escape(var_export($value, TRUE)) . '</pre>'); } } } }
/** * @return array */ public function getParams() { return $this->filter->getParams(); }
/** * Add a filter to the queue based on priority * * @param FilterInterface $filter A Filter * @param integer $priority The command priority, usually between 1 (high priority) and 5 (lowest), * default is 3. If no priority is set, the command priority will be used * instead. * * @return FilterChain */ public function addFilter(FilterInterface $filter, $priority = null) { $priority = $priority == null ? $filter->getPriority() : $priority; $this->_queue->enqueue($filter, $priority); return $this; }
/** * @param FilterInterface $filter * * @return FiltersCollection */ public function add(FilterInterface $filter) { $this->filters[$filter->getPriority()][] = $filter; $this->sorted = null; return $this; }
/** * Gets a sub filter * @param string $name * @return FilterInterface */ public function getSubFilter($name) { return $this->proxyFilter->getSubFilter($name); }
protected function apply_filters() { $wrap = new FilterInterface($this->request); for ($i = 0; $i < count($this->filters); $i++) { $f = $this->filters[$i]; $wrap->add($f['name'], $f['value'], $f['operation']); } $this->event->trigger("beforeFilter", $wrap); $wrap->store(); }
/** * @param string $column_name * @param string $value * @param boolean $equal * * @return FilterInterface */ public function findBy($column_name, $value, $equal = true) { $source = $this->getSourceM($column_name); $this->filter->addWhere(array('source' => $source, 'field' => $column_name, 'value' => $value, 'equal' => $equal)); return $this; }