Add Check Route Access to Install Handler

This commit is contained in:
Jack Anderson 2024-01-12 09:47:47 +00:00
parent 4cc11dc63a
commit d98d898ca9

View file

@ -32,6 +32,7 @@ use App\Engine\LegacyHandler\LegacyScopeState;
use App\Engine\Model\Feedback;
use App\Install\Service\Installation\InstallStatus;
use App\Install\Service\InstallationUtilsTrait;
use App\Install\Service\InstallPreChecks;
use PDO;
use PDOException;
use Psr\Log\LoggerInterface;
@ -202,6 +203,43 @@ class InstallHandler extends LegacyHandler
return $feedback;
}
public function runCheckRouteAccess(array $inputArray): FeedBack
{
$results = [];
$url = $inputArray['site_host'];
require_once "core/backend/Install/Service/InstallPreChecks.php";
$installChecks = new InstallPreChecks($this->logger);
$results[] = $installChecks->checkMainPage($url);
$results[] = $installChecks->checkGraphQlAPI($url);
$modStrings = $installChecks->getLanguageStrings();
$feedback = new Feedback();
$feedback->setSuccess(true);
$warnings = [];
foreach ($results as $result) {
if (is_array($result['errors'])) {
foreach ($result['errors'] as $error) {
if (in_array($error, $modStrings)) {
$warnings[] = "Check Failed:" . $error . " Please refer to the logs/install.log";
}
}
continue;
}
if (!empty($result['errors'])) {
$warnings[] = $result['errors'];
}
}
if (isset($warnings)){
$feedback->setWarnings($warnings);
}
return $feedback;
}
/**
* @param array $inputArray
* @return bool