src/Charcoal/Admin/Action/Object/AbstractSaveAction.php
public function addFeedbackFromValidation(ModelInterface $obj, $filters = null)
    {
        $validator = $obj->validator();
        $levels    = [ ModelValidator::ERROR, ModelValidator::WARNING, ModelValidator::NOTICE ];

        if (is_string($filters) && in_array($filters, $levels)) {
            $results = call_user_func([ $validator, $filters.'Results' ]);
            foreach ($results as $result) {
                $this->addFeedback($result->level(), $result->message());
            }

            return $this;
        }

        if (!is_array($filters) && $filters !== null) {
            throw new InvalidArgumentException(
                'Filters must be an array of validation levels or NULL'
            );
        }

        $validation = $validator->results();
        foreach ($validation as $level => $results) {
            if ($filters === null || in_array($level, $filters)) {
                foreach ($results as $result) {
                    $this->addFeedback($result->level(), $result->message());
                }
            }
        }

        return $this;
    }
public function addFeedbackFromValidation(ModelInterface $obj, $filters = null)
    {
        $validator = $obj->validator();
        $levels    = [ ModelValidator::ERROR, ModelValidator::WARNING, ModelValidator::NOTICE ];

        if (is_string($filters) && in_array($filters, $levels)) {
            $results = call_user_func([ $validator, $filters.'Results' ]);
            foreach ($results as $result) {
                $this->addFeedback($result->level(), $result->message());
            }

            return $this;
        }

        if (!is_array($filters) && $filters !== null) {
            throw new InvalidArgumentException(
                'Filters must be an array of validation levels or NULL'
            );
        }

        $validation = $validator->results();
        foreach ($validation as $level => $results) {
            if ($filters === null || in_array($level, $filters)) {
                foreach ($results as $result) {
                    $this->addFeedback($result->level(), $result->message());
                }
            }
        }

        return $this;
    }
public function addFeedbackFromValidation ( ModelInterface $ obj , $ filters = null ) { $ validator = $ obj -> validator ( ) ; $ levels = [ ModelValidator :: ERROR , ModelValidator :: WARNING , ModelValidator :: NOTICE ] ; if ( is_string ( $ filters ) && in_array ( $ filters , $ levels ) ) { $ results = call_user_func ( [ $ validator , $ filters . 'Results' ] ) ; foreach ( $ results as $ result ) { $ this -> addFeedback ( $ result -> level ( ) , $ result -> message ( ) ) ; } return $ this ; } if ( ! is_array ( $ filters ) && $ filters !== null ) { throw new InvalidArgumentException ( 'Filters must be an array of validation levels or NULL' ) ; } $ validation = $ validator -> results ( ) ; foreach ( $ validation as $ level => $ results ) { if ( $ filters === null || in_array ( $ level , $ filters ) ) { foreach ( $ results as $ result ) { $ this -> addFeedback ( $ result -> level ( ) , $ result -> message ( ) ) ; } } } return $ this ; }
Merge the given object's validation results the response feedback.

@param  ModelInterface       $obj     The validated object.
@param  string[]|string|null $filters Filter the levels to merge.
@throws InvalidArgumentException If the filters are invalid.
@return SaveAction Chainable
Merge the given object s validation results the response feedback .