Automattic\WooCommerce\Blueprint
ImportStep::validate_step_schemas
Validate the step schemas.
Method of the class: ImportStep{}
No Hooks.
Returns
true|false
. True if the step schemas are valid, false otherwise.
Usage
// protected - for code of main (parent) or child class $result = $this->validate_step_schemas( $importer, $result );
- $importer(StepProcessor) (required)
- The importer.
- $result(StepProcessorResult) (required)
- The result object to add messages to.
ImportStep::validate_step_schemas() ImportStep::validate step schemas code WC 9.9.5
protected function validate_step_schemas( StepProcessor $importer, StepProcessorResult $result ) { $step_schema = call_user_func( array( $importer->get_step_class(), 'get_schema' ) ); $validate = $this->validator->validate( $this->step_definition, wp_json_encode( $step_schema ) ); if ( ! $validate->isValid() ) { $result->add_error( "Schema validation failed for step {$this->step_definition->step}" ); $errors = ( new ErrorFormatter() )->format( $validate->error() ); $formatted_errors = array(); foreach ( $errors as $value ) { $formatted_errors[] = implode( "\n", $value ); } $result->add_error( implode( "\n", $formatted_errors ) ); return false; } return true; }