src/Norm/Filter/Filter.php
public static function fromSchema($schema, $preFilter = array(), $postFilter = array())
    {
        $rules = array();

        foreach ($preFilter as $key => $filter) {
            $filter = explode('|', $filter);

            foreach ($filter as $f) {
                $rules[$key][] = trim($f);
            }
        }

        foreach ($schema as $k => $field) {
            if (is_null($field)) {
                continue;
            }

            $rules[$k] = array(
                'label' => $field['label'],
                'filter' => $field->filter(),
            );
        }

        foreach ($postFilter as $key => $filter) {
            $filter = explode('|', $filter);

            foreach ($filter as $f) {
                $rules[$key]['filter'][] = trim($f);
            }
        }

        return new static($rules);
    }
public static function fromSchema($schema, $preFilter = array(), $postFilter = array())
    {
        $rules = array();

        foreach ($preFilter as $key => $filter) {
            $filter = explode('|', $filter);

            foreach ($filter as $f) {
                $rules[$key][] = trim($f);
            }
        }

        foreach ($schema as $k => $field) {
            if (is_null($field)) {
                continue;
            }

            $rules[$k] = array(
                'label' => $field['label'],
                'filter' => $field->filter(),
            );
        }

        foreach ($postFilter as $key => $filter) {
            $filter = explode('|', $filter);

            foreach ($filter as $f) {
                $rules[$key]['filter'][] = trim($f);
            }
        }

        return new static($rules);
    }
public static function fromSchema ( $ schema , $ preFilter = array ( ) , $ postFilter = array ( ) ) { $ rules = array ( ) ; foreach ( $ preFilter as $ key => $ filter ) { $ filter = explode ( '|' , $ filter ) ; foreach ( $ filter as $ f ) { $ rules [ $ key ] [ ] = trim ( $ f ) ; } } foreach ( $ schema as $ k => $ field ) { if ( is_null ( $ field ) ) { continue ; } $ rules [ $ k ] = array ( 'label' => $ field [ 'label' ] , 'filter' => $ field -> filter ( ) , ) ; } foreach ( $ postFilter as $ key => $ filter ) { $ filter = explode ( '|' , $ filter ) ; foreach ( $ filter as $ f ) { $ rules [ $ key ] [ 'filter' ] [ ] = trim ( $ f ) ; } } return new static ( $ rules ) ; }
Static method to create instance of filter from database schema configuration.

@param array $schema      Database schema configuration
@param array $preFilter   Filters that will be run before the filter
@param array $postFilter  Filters that will be run after the filter

@return \Norm\Filter\Filter
Static method to create instance of filter from database schema configuration .