2019-11-27 22:19:20 +08:00
|
|
|
<?php
|
|
|
|
|
2019-12-13 04:07:35 +08:00
|
|
|
namespace Modules\Importer\Console\Commands;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
use App\Contracts\Command;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
2019-12-13 04:07:35 +08:00
|
|
|
use Modules\Importer\Services\ImporterService;
|
2019-11-27 22:19:20 +08:00
|
|
|
|
|
|
|
class ImportFromClassicCommand extends Command
|
|
|
|
{
|
|
|
|
protected $signature = 'phpvms:importer {db_host} {db_name} {db_user} {db_pass?} {table_prefix=phpvms_}';
|
|
|
|
protected $description = 'Import from an older version of phpVMS';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run dev related commands
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
$creds = [
|
|
|
|
'host' => $this->argument('db_host'),
|
|
|
|
'name' => $this->argument('db_name'),
|
|
|
|
'user' => $this->argument('db_user'),
|
|
|
|
'pass' => $this->argument('db_pass'),
|
|
|
|
'table_prefix' => $this->argument('table_prefix'),
|
|
|
|
];
|
|
|
|
|
|
|
|
$importerSvc = new ImporterService();
|
|
|
|
|
|
|
|
$importerSvc->saveCredentials($creds);
|
2019-12-02 22:57:35 +08:00
|
|
|
$manifest = $importerSvc->generateImportManifest();
|
2019-11-27 22:19:20 +08:00
|
|
|
|
2019-12-02 22:57:35 +08:00
|
|
|
foreach ($manifest as $record) {
|
2019-11-27 22:19:20 +08:00
|
|
|
try {
|
2019-12-02 22:57:35 +08:00
|
|
|
$importerSvc->run($record['importer'], $record['start']);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
Log::error($e->getMessage());
|
2019-11-27 22:19:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|