public function setDefaultFilter(array $default_filter, $use_on_reset = true)
	{
		foreach ($default_filter as $key => $value) {
			$filter = $this->getFilter($key);

			if (!$filter) {
				throw new DataGridException("Can not set default value to nonexisting filter [$key]");
			}

			if ($filter instanceof Filter\FilterMultiSelect && !is_array($value)) {
				throw new DataGridException(
					"Default value of filter [$key] - MultiSelect has to be an array"
				);
			}

			if ($filter instanceof Filter\FilterRange || $filter instanceof Filter\FilterDateRange) {
				if (!is_array($value)) {
					throw new DataGridException(
						"Default value of filter [$key] - Range/DateRange has to be an array [from/to => ...]"
					);
				}

				$temp = $value;
				unset($temp['from'], $temp['to']);

				if (!empty($temp)) {
					throw new DataGridException(
						"Default value of filter [$key] - Range/DateRange can contain only [from/to => ...] values"
					);
				}
			}
		}

		$this->default_filter = $default_filter;
		$this->default_filter_use_on_reset = (bool) $use_on_reset;

		return $this;
	}
public function setDefaultFilter(array $default_filter, $use_on_reset = true)
	{
		foreach ($default_filter as $key => $value) {
			$filter = $this->getFilter($key);

			if (!$filter) {
				throw new DataGridException("Can not set default value to nonexisting filter [$key]");
			}

			if ($filter instanceof Filter\FilterMultiSelect && !is_array($value)) {
				throw new DataGridException(
					"Default value of filter [$key] - MultiSelect has to be an array"
				);
			}

			if ($filter instanceof Filter\FilterRange || $filter instanceof Filter\FilterDateRange) {
				if (!is_array($value)) {
					throw new DataGridException(
						"Default value of filter [$key] - Range/DateRange has to be an array [from/to => ...]"
					);
				}

				$temp = $value;
				unset($temp['from'], $temp['to']);

				if (!empty($temp)) {
					throw new DataGridException(
						"Default value of filter [$key] - Range/DateRange can contain only [from/to => ...] values"
					);
				}
			}
		}

		$this->default_filter = $default_filter;
		$this->default_filter_use_on_reset = (bool) $use_on_reset;

		return $this;
	}
public function setDefaultFilter ( array $ default_filter , $ use_on_reset = true ) { foreach ( $ default_filter as $ key => $ value ) { $ filter = $ this -> getFilter ( $ key ) ; if ( ! $ filter ) { throw new DataGridException ( "Can not set default value to nonexisting filter [$key]" ) ; } if ( $ filter instanceof Filter \ FilterMultiSelect && ! is_array ( $ value ) ) { throw new DataGridException ( "Default value of filter [$key] - MultiSelect has to be an array" ) ; } if ( $ filter instanceof Filter \ FilterRange || $ filter instanceof Filter \ FilterDateRange ) { if ( ! is_array ( $ value ) ) { throw new DataGridException ( "Default value of filter [$key] - Range/DateRange has to be an array [from/to => ...]" ) ; } $ temp = $ value ; unset ( $ temp [ 'from' ] , $ temp [ 'to' ] ) ; if ( ! empty ( $ temp ) ) { throw new DataGridException ( "Default value of filter [$key] - Range/DateRange can contain only [from/to => ...] values" ) ; } } } $ this -> default_filter = $ default_filter ; $ this -> default_filter_use_on_reset = ( bool ) $ use_on_reset ; return $ this ; }
If we want to sent some initial filter
@param array $filter
@param bool  $use_on_reset
@return static
If we want to sent some initial filter