38 lines
1,010 B
PHP
38 lines
1,010 B
PHP
<?php
|
|
|
|
namespace App\Services\Import;
|
|
|
|
use App\Enums\Portal;
|
|
|
|
/**
|
|
* Hält den Kontext für einen Import-Lauf.
|
|
*/
|
|
final class ImportContext
|
|
{
|
|
public readonly ?Portal $portalEnum;
|
|
|
|
public readonly ?string $connection;
|
|
|
|
public function __construct(
|
|
public readonly string $portal, // 'presseecho' | 'businessportal24' | 'all'
|
|
public readonly bool $dryRun = false,
|
|
public readonly bool $force = false,
|
|
) {
|
|
if ($portal === 'all') {
|
|
$this->portalEnum = null;
|
|
$this->connection = null;
|
|
} else {
|
|
$this->portalEnum = Portal::from($portal);
|
|
$this->connection = match ($portal) {
|
|
'presseecho' => 'mysql_presseecho',
|
|
'businessportal24' => 'mysql_businessportal',
|
|
default => throw new \InvalidArgumentException("Unbekanntes Portal: {$portal}"),
|
|
};
|
|
}
|
|
}
|
|
|
|
public function legacyPortalValue(): string
|
|
{
|
|
return $this->portal;
|
|
}
|
|
}
|