2021-11-30 11:20:42 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace AIO\Data;
|
|
|
|
|
|
|
|
|
|
use AIO\Auth\PasswordGenerator;
|
|
|
|
|
|
2024-10-07 10:12:43 +02:00
|
|
|
readonly class Setup {
|
2021-11-30 11:20:42 +01:00
|
|
|
public function __construct(
|
2024-10-07 10:12:43 +02:00
|
|
|
private PasswordGenerator $passwordGenerator,
|
|
|
|
|
private ConfigurationManager $configurationManager,
|
|
|
|
|
) {
|
2021-11-30 11:20:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function Setup() : string {
|
|
|
|
|
if(!$this->CanBeInstalled()) {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-30 13:04:06 +01:00
|
|
|
$password = $this->passwordGenerator->GeneratePassword(8);
|
2021-11-30 11:20:42 +01:00
|
|
|
$this->configurationManager->SetPassword($password);
|
|
|
|
|
return $password;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function CanBeInstalled() : bool {
|
|
|
|
|
return !file_exists(DataConst::GetConfigFile());
|
|
|
|
|
}
|
|
|
|
|
}
|