WC_WCCOM_Site_Installation_Step_Unpack_Product{}WC 1.0

WC_WCCOM_Site_Installation_Step_Unpack_Product class

No Hooks.

Usage

$WC_WCCOM_Site_Installation_Step_Unpack_Product = new WC_WCCOM_Site_Installation_Step_Unpack_Product();
// use class methods

Methods

  1. public __construct( $state )
  2. public run()

WC_WCCOM_Site_Installation_Step_Unpack_Product{} code WC 9.4.2

class WC_WCCOM_Site_Installation_Step_Unpack_Product implements WC_WCCOM_Site_Installation_Step {
	/**
	 * The current installation state.
	 *
	 * @var WC_WCCOM_Site_Installation_State
	 */
	protected $state;

	/**
	 * Constructor.
	 *
	 * @param array $state The current installation state.
	 */
	public function __construct( $state ) {
		$this->state = $state;
	}

	/**
	 * Run the step installation process.
	 *
	 * @return WC_WCCOM_Site_Installation_State
	 * @throws WC_REST_WCCOM_Site_Installer_Error If the package unpacked path is not returned.
	 */
	public function run() {
		$upgrader      = WC_WCCOM_Site_Installer::get_wp_upgrader();
		$unpacked_path = $upgrader->unpack_package( $this->state->get_download_path(), true );

		if ( empty( $unpacked_path ) ) {
			throw new Installer_Error( Installer_Error_Codes::MISSING_UNPACKED_PATH );
		}

		$this->state->set_unpacked_path( $unpacked_path );

		return $this->state;
	}
}