Remove interact from command and implement bootstrap method

Signed-off-by: Vitor Mattos <vitor@php.rio>
This commit is contained in:
Vitor Mattos
2021-07-18 10:11:39 -03:00
committed by Julius Härtl
parent e01e4cf1a7
commit 6714c89220
7 changed files with 91 additions and 89 deletions

View File

@@ -111,10 +111,10 @@ class BoardImportService {
$this->cardMapper = $cardMapper;
$this->assignmentMapper = $assignmentMapper;
$this->commentsManager = $commentsManager;
$this->setData(new \stdClass());
}
public function import(): void {
$this->bootstrap();
try {
$this->importBoard();
$this->importAcl();
@@ -129,12 +129,6 @@ class BoardImportService {
}
}
public function validate(): void {
$this->validateSystem();
$this->validateConfig();
$this->validateUsers();
}
public function validateSystem(): void {
if (!in_array($this->getSystem(), $this->getAllowedImportSystems())) {
throw new NotFoundException('Invalid system');
@@ -327,7 +321,7 @@ class BoardImportService {
$this->getImportSystem()->importParticipants();
}
final public function setData(\stdClass $data): void {
public function setData(\stdClass $data): void {
$this->data = $data;
}
@@ -355,7 +349,7 @@ class BoardImportService {
* @param string $configName config name
* @return mixed
*/
public function getConfig(string $configName = null) {
public function getConfig(string $configName) {
if (!property_exists($this->config, $configName)) {
return;
}
@@ -363,19 +357,10 @@ class BoardImportService {
}
/**
* @param mixed $config
* @param \stdClass $config
* @return self
*/
public function setConfigInstance($config): self {
if (is_string($config)) {
if (!is_file($config)) {
throw new NotFoundException('Please inform a valid config json file');
}
$config = json_decode(file_get_contents($config));
if (!is_object($config)) {
throw new NotFoundException('Please inform a valid config json file');
}
}
$this->config = $config;
return $this;
}
@@ -413,7 +398,13 @@ class BoardImportService {
$this->setConfig('owner', $owner);
}
public function validateUsers(): void {
$this->getImportSystem()->validateUsers();
protected function validateData(): void {
}
public function bootstrap(): void {
$this->validateSystem();
$this->validateConfig();
$this->validateData();
$this->getImportSystem()->bootstrap();
}
}