lithium\security\auth\adapter\Form::_filters()

protected method

Iterates over the filters configured in $_filters which are applied to submitted form data before it is used in the query.

Parameters

  • array $data

    The array of raw form data to be filtered.

Returns

array

Callback result.

Source

	protected function _filters($data) {
		$result = [];

		foreach ($this->_fields as $from => $to) {
			$result[$to] = isset($data[$from]) ? $data[$from] : null;

			if (!isset($this->_filters[$from])) {
				$result[$to] = is_scalar($result[$to]) ? $result[$to] : null;
				continue;
			}
			if ($this->_filters[$from] === false) {
				continue;
			}
			if (!is_callable($this->_filters[$from])) {
				$message = "Authentication filter for `{$from}` is not callable.";
				throw new UnexpectedValueException($message);
			}
			$result[$to] = call_user_func($this->_filters[$from], $result[$to]);
		}
		if (!isset($this->_filters[0])) {
			return $result;
		}
		if (!is_callable($this->_filters[0])) {
			throw new UnexpectedValueException("Authentication filter is not callable.");
		}
		return call_user_func($this->_filters[0], $result);
	}