Automattic\WooCommerce\Blueprint
ImportStep::can_import
Check if the step can be imported.
Method of the class: ImportStep{}
No Hooks.
Returns
true|false. True if the step can be imported, false otherwise.
Usage
// protected - for code of main (parent) or child class $result = $this->can_import( $result );
- $result(StepProcessorResult) (required) (passed by reference — &)
- The result object to add messages to.
ImportStep::can_import() ImportStep::can import code WC 10.7.0
protected function can_import( &$result ) {
// Check if the importer exists.
if ( ! isset( $this->indexed_importers[ $this->step_definition->step ] ) ) {
$result->add_error( 'Unable to find an importer' );
return false;
}
$importer = $this->indexed_importers[ $this->step_definition->step ];
// Validate importer is a step processor before processing.
if ( ! $importer instanceof StepProcessor ) {
$result->add_error( 'Incorrect importer type' );
return false;
}
// Validate steps schemas before processing.
if ( ! $this->validate_step_schemas( $importer, $result ) ) {
$result->add_error( 'Schema validation failed for step' );
return false;
}
// Validate step capabilities before processing.
if ( ! $importer->check_step_capabilities( $this->step_definition ) ) {
$result->add_error( 'User does not have the required capabilities to run step' );
return false;
}
return true;
}