new changes
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Marketplace;
|
||||
|
||||
class MarketplaceCommandFactory
|
||||
{
|
||||
public function installPlugin(string $tenantId, array $input): array
|
||||
{
|
||||
return [
|
||||
'tenant_id' => $tenantId,
|
||||
'type' => 'PLUGIN_INSTALL',
|
||||
'idempotency_key' => $input['idempotency_key'] ?? uniqid('plugin_install_', true),
|
||||
'args' => $input,
|
||||
];
|
||||
}
|
||||
|
||||
public function updatePlugin(string $tenantId, array $input): array
|
||||
{
|
||||
return [
|
||||
'tenant_id' => $tenantId,
|
||||
'type' => 'PLUGIN_UPDATE',
|
||||
'idempotency_key' => $input['idempotency_key'] ?? uniqid('plugin_update_', true),
|
||||
'args' => $input,
|
||||
];
|
||||
}
|
||||
|
||||
public function removePlugin(string $tenantId, array $input): array
|
||||
{
|
||||
return [
|
||||
'tenant_id' => $tenantId,
|
||||
'type' => 'PLUGIN_REMOVE',
|
||||
'idempotency_key' => $input['idempotency_key'] ?? uniqid('plugin_remove_', true),
|
||||
'args' => $input,
|
||||
];
|
||||
}
|
||||
}
|
||||
42
panel-api/app/Modules/Marketplace/MarketplaceController.php
Normal file
42
panel-api/app/Modules/Marketplace/MarketplaceController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Marketplace;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
class MarketplaceController extends Controller
|
||||
{
|
||||
public function __construct(private readonly MarketplaceWorkflowService $workflow)
|
||||
{
|
||||
}
|
||||
|
||||
public function catalog(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'data' => [
|
||||
'items' => [],
|
||||
'meta' => ['source' => 'placeholder-market-catalog'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function install(Request $request): JsonResponse
|
||||
{
|
||||
$tenantId = (string) $request->attributes->get('tenant_id', '');
|
||||
return response()->json(['data' => $this->workflow->install($tenantId, $request->all())], 202);
|
||||
}
|
||||
|
||||
public function update(Request $request): JsonResponse
|
||||
{
|
||||
$tenantId = (string) $request->attributes->get('tenant_id', '');
|
||||
return response()->json(['data' => $this->workflow->update($tenantId, $request->all())], 202);
|
||||
}
|
||||
|
||||
public function remove(Request $request): JsonResponse
|
||||
{
|
||||
$tenantId = (string) $request->attributes->get('tenant_id', '');
|
||||
return response()->json(['data' => $this->workflow->remove($tenantId, $request->all())], 202);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Marketplace;
|
||||
|
||||
use App\Modules\Jobs\CommandOrchestrator;
|
||||
|
||||
class MarketplaceWorkflowService
|
||||
{
|
||||
public function __construct(
|
||||
private readonly CommandOrchestrator $orchestrator,
|
||||
private readonly MarketplaceCommandFactory $commands
|
||||
) {
|
||||
}
|
||||
|
||||
public function install(string $tenantId, array $input): array
|
||||
{
|
||||
return $this->orchestrator->dispatch($this->commands->installPlugin($tenantId, $input));
|
||||
}
|
||||
|
||||
public function update(string $tenantId, array $input): array
|
||||
{
|
||||
return $this->orchestrator->dispatch($this->commands->updatePlugin($tenantId, $input));
|
||||
}
|
||||
|
||||
public function remove(string $tenantId, array $input): array
|
||||
{
|
||||
return $this->orchestrator->dispatch($this->commands->removePlugin($tenantId, $input));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user