protected function applyGenericFilters($datatable)
    {
        if ($datatable instanceof DataTable\Map) {
            $tables = $datatable->getDataTables();
            foreach ($tables as $table) {
                $this->applyGenericFilters($table);
            }
            return;
        }

        $tableDisabledFilters = $datatable->getMetadata(DataTable::GENERIC_FILTERS_TO_DISABLE_METADATA_NAME) ?: [];
        $genericFilters = $this->getGenericFiltersHavingDefaultValues();

        $filterApplied = false;
        foreach ($genericFilters as $filterMeta) {
            $filterName = $filterMeta[0];
            $filterParams = $filterMeta[1];
            $filterParameters = array();
            $exceptionRaised = false;

            if (in_array($filterName, $this->disabledFilters)
                || in_array($filterName, $tableDisabledFilters)
            ) {
                continue;
            }

            foreach ($filterParams as $name => $info) {
                if (!is_array($info)) {
                    // hard coded value that cannot be changed via API, see eg $naturalSort = true in 'Sort'
                    $filterParameters[] = $info;
                } else {
                    // parameter type to cast to
                    $type = $info[0];

                    // default value if specified, when the parameter doesn't have a value
                    $defaultValue = null;
                    if (isset($info[1])) {
                        $defaultValue = $info[1];
                    }

                    try {
                        $value = Common::getRequestVar($name, $defaultValue, $type, $this->request);
                        settype($value, $type);
                        $filterParameters[] = $value;
                    } catch (Exception $e) {
                        $exceptionRaised = true;
                        break;
                    }
                }
            }

            if (!$exceptionRaised) {
                $datatable->filter($filterName, $filterParameters);
                $filterApplied = true;
            }
        }

        return $filterApplied;
    }
protected function applyGenericFilters($datatable)
    {
        if ($datatable instanceof DataTable\Map) {
            $tables = $datatable->getDataTables();
            foreach ($tables as $table) {
                $this->applyGenericFilters($table);
            }
            return;
        }

        $tableDisabledFilters = $datatable->getMetadata(DataTable::GENERIC_FILTERS_TO_DISABLE_METADATA_NAME) ?: [];
        $genericFilters = $this->getGenericFiltersHavingDefaultValues();

        $filterApplied = false;
        foreach ($genericFilters as $filterMeta) {
            $filterName = $filterMeta[0];
            $filterParams = $filterMeta[1];
            $filterParameters = array();
            $exceptionRaised = false;

            if (in_array($filterName, $this->disabledFilters)
                || in_array($filterName, $tableDisabledFilters)
            ) {
                continue;
            }

            foreach ($filterParams as $name => $info) {
                if (!is_array($info)) {
                    // hard coded value that cannot be changed via API, see eg $naturalSort = true in 'Sort'
                    $filterParameters[] = $info;
                } else {
                    // parameter type to cast to
                    $type = $info[0];

                    // default value if specified, when the parameter doesn't have a value
                    $defaultValue = null;
                    if (isset($info[1])) {
                        $defaultValue = $info[1];
                    }

                    try {
                        $value = Common::getRequestVar($name, $defaultValue, $type, $this->request);
                        settype($value, $type);
                        $filterParameters[] = $value;
                    } catch (Exception $e) {
                        $exceptionRaised = true;
                        break;
                    }
                }
            }

            if (!$exceptionRaised) {
                $datatable->filter($filterName, $filterParameters);
                $filterApplied = true;
            }
        }

        return $filterApplied;
    }
protected function applyGenericFilters ( $ datatable ) { if ( $ datatable instanceof DataTable \ Map ) { $ tables = $ datatable -> getDataTables ( ) ; foreach ( $ tables as $ table ) { $ this -> applyGenericFilters ( $ table ) ; } return ; } $ tableDisabledFilters = $ datatable -> getMetadata ( DataTable :: GENERIC_FILTERS_TO_DISABLE_METADATA_NAME ) ? : [ ] ; $ genericFilters = $ this -> getGenericFiltersHavingDefaultValues ( ) ; $ filterApplied = false ; foreach ( $ genericFilters as $ filterMeta ) { $ filterName = $ filterMeta [ 0 ] ; $ filterParams = $ filterMeta [ 1 ] ; $ filterParameters = array ( ) ; $ exceptionRaised = false ; if ( in_array ( $ filterName , $ this -> disabledFilters ) || in_array ( $ filterName , $ tableDisabledFilters ) ) { continue ; } foreach ( $ filterParams as $ name => $ info ) { if ( ! is_array ( $ info ) ) { // hard coded value that cannot be changed via API, see eg $naturalSort = true in 'Sort' $ filterParameters [ ] = $ info ; } else { // parameter type to cast to $ type = $ info [ 0 ] ; // default value if specified, when the parameter doesn't have a value $ defaultValue = null ; if ( isset ( $ info [ 1 ] ) ) { $ defaultValue = $ info [ 1 ] ; } try { $ value = Common :: getRequestVar ( $ name , $ defaultValue , $ type , $ this -> request ) ; settype ( $ value , $ type ) ; $ filterParameters [ ] = $ value ; } catch ( Exception $ e ) { $ exceptionRaised = true ; break ; } } } if ( ! $ exceptionRaised ) { $ datatable -> filter ( $ filterName , $ filterParameters ) ; $ filterApplied = true ; } } return $ filterApplied ; }
Apply generic filters to the DataTable object resulting from the API Call.
Disable this feature by setting the parameter disable_generic_filters to 1 in the API call request.

@param DataTable $datatable
@return bool
Apply generic filters to the DataTable object resulting from the API Call . Disable this feature by setting the parameter disable_generic_filters to 1 in the API call request .