new changes

This commit is contained in:
Niranjan
2026-04-07 20:29:49 +05:30
parent 8fe63c7cf4
commit 31fe556bb0
79 changed files with 2917 additions and 0 deletions

View File

@@ -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,
];
}
}

View 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);
}
}

View File

@@ -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));
}
}