WC_WCCOM_Site_Installation_Manager::can_run_installation()protectedWC 1.0

Check if the installation can be run.

Method of the class: WC_WCCOM_Site_Installation_Manager{}

No Hooks.

Return

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->can_run_installation( $run_until_step, $state );
$run_until_step(string) (required)
Run until this step.
$state(WC_WCCOM_Site_Installation_State) (required)
Installation state.

WC_WCCOM_Site_Installation_Manager::can_run_installation() code WC 9.4.2

protected function can_run_installation( $run_until_step, $state ) {

	if ( $state->get_last_step_status() === \WC_WCCOM_Site_Installation_State::STEP_STATUS_IN_PROGRESS ) {
		throw new Installer_Error( Installer_Error_Codes::INSTALLATION_ALREADY_RUNNING );
	}

	if ( $state->get_last_step_status() === \WC_WCCOM_Site_Installation_State::STEP_STATUS_FAILED ) {
		throw new Installer_Error( Installer_Error_Codes::INSTALLATION_FAILED );
	}

	if ( $state->get_last_step_name() === self::STEPS[ count( self::STEPS ) - 1 ] ) {
		throw new Installer_Error( Installer_Error_Codes::ALL_INSTALLATION_STEPS_RUN );
	}

	if ( array_search( $state->get_last_step_name(), self::STEPS, true ) >= array_search(
		$run_until_step,
		self::STEPS,
		true
	) ) {
		throw new Installer_Error( Installer_Error_Codes::REQUESTED_STEP_ALREADY_RUN );
	}

	if ( ! is_writable( WP_CONTENT_DIR ) ) {
		throw new Installer_Error( Installer_Error_Codes::FILESYSTEM_REQUIREMENTS_NOT_MET );
	}
}