Feature: Creating Skeleton for import command, interfaces, shopify importer
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\MigrateImport;
|
||||
|
||||
class ImportSpec
|
||||
{
|
||||
public function __construct(
|
||||
public readonly string $source,
|
||||
public readonly string $type,
|
||||
public readonly ?string $filePath = null,
|
||||
public readonly ?array $credentials = null,
|
||||
) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\MigrateImport;
|
||||
|
||||
interface Importer
|
||||
{
|
||||
public function import(ImportSpec $spec): void;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\MigrateImport;
|
||||
|
||||
use Modules\Core\MigrateImport\Shopify\ShopifyExportImporter;
|
||||
|
||||
class ImporterFactory
|
||||
{
|
||||
public static function make(ImportSpec $spec): Importer
|
||||
{
|
||||
return match ([$spec->source, $spec->type]) {
|
||||
["shopify", "export"] => new ShopifyExportImporter(),
|
||||
// ["shopify", "api"] => new ShopifyApiImporter(),
|
||||
// ["woocommerce", "export"] => new WooCommerceExportImporter(),
|
||||
// ["woocommerce", "api"] => new WooCommerceApiImporter(),
|
||||
default => throw new \InvalidArgumentException(
|
||||
"No importer available for source \"{$spec->source}\" with type \"{$spec->type}\".",
|
||||
),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\MigrateImport;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class RunMigrateImportJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public readonly ImportSpec $spec,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$importer = ImporterFactory::make($this->spec);
|
||||
$importer->import($this->spec);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\MigrateImport\Shopify;
|
||||
|
||||
use Modules\Core\MigrateImport\ImportSpec;
|
||||
use Modules\Core\MigrateImport\Importer;
|
||||
|
||||
class ShopifyExportImporter implements Importer
|
||||
{
|
||||
public function import(ImportSpec $spec): void
|
||||
{
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user