| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/public_html/wp-content/plugins/wappointment/app/Installation/ |
Upload File : |
<?php
namespace Wappointment\Installation;
use Wappointment\WP\Helpers as WPHelpers;
// @codingStandardsIgnoreFile
class AbstractProcess
{
protected $errors = [];
protected $steps = [];
protected $key = '';
protected $complete = \false;
protected $currentStep = '';
public function __construct()
{
if (!$this->isUpToDate()) {
$errors_bag = $this->testSystem();
if (empty($errors_bag)) {
$this->currentStep = $this->loadCurrentStep();
$this->runStep();
} else {
$this->errors = $errors_bag;
}
//once we ran the installation test and the instalation process we check that all is fine
if (!empty($this->errors)) {
throw new \WappointmentValidationException('Installation interrupted', 1, null, $this->errors);
}
}
}
public function result()
{
if (!empty($this->errors)) {
return $this->errors;
}
return \true;
}
protected function testSystem()
{
return (new \Wappointment\Installation\Check())->getErrors();
}
protected function isUpToDate()
{
return \true;
}
protected function runStep()
{
if (empty($this->currentStep)) {
$this->setNextStep();
}
$currentStep = $this->currentStep;
$runningStepObject = new $currentStep();
$errors_step = $runningStepObject->getErrors();
if (empty($errors_step)) {
$this->stepSuccess();
} else {
$this->errors = $errors_step;
}
}
protected function stepSuccess()
{
$this->setNextStep();
if (!$this->complete) {
$this->runStep();
}
}
protected function setNextStep()
{
$indexCurrentStep = 0;
if (!empty($this->currentStep)) {
$indexCurrentStep = \array_search($this->currentStep, $this->steps);
if ($indexCurrentStep === \false) {
throw new \WappointmentException('Instalation step cannot be found(' . $this->currentStep . ')');
}
$indexCurrentStep++;
}
if (!isset($this->steps[$indexCurrentStep])) {
throw new \WappointmentException('Instalation failure trying to run inexistant step');
return;
}
$this->currentStep = $this->steps[$indexCurrentStep];
// only when we reach the end of the instalation
if ($this->currentStep === \true) {
//we then set a flag to say we've been through the instalation
WPHelpers::deleteOption($this->key);
return $this->completed();
}
//we save the new step whil the instalation process is on
$this->saveCurrentStep($this->currentStep);
}
protected function saveCurrentStep($stepValue)
{
return WPHelpers::setOption($this->key, $stepValue);
}
protected function loadCurrentStep()
{
return WPHelpers::getOption($this->key);
}
protected function completed()
{
return \true;
}
}