mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-17 06:15:20 +00:00
ModuleInstaller has the same shape as Updater (moved in 7cf72b9f): every method is public static, no constructor, no DI, no instance state. It orchestrates marketplace operations — fetch catalog, download zip, verify checksum, unzip, copy files, run module:migrate/module:enable, dispatch install/enable events — but the orchestration itself is stateless procedural plumbing.
Emitting events and writing to the Module eloquent model doesn't make it a service; plenty of static helpers touch models. The distinguishing factor is stateless-procedural vs DI-injected-workflow, and this is clearly the former.
4 consumers updated: ModulesController, ModuleInstallationController, InstallModuleCommand, and a doc comment in config/invoiceshelf.php. 350 tests still pass.
This leaves app/Services/ with no single-file driver-less subdirs except Mail/Module/Pdf/Storage which have multiple files each. The Module/ subdir in Services is now deleted entirely — the marketplace installer moved out and there were no other files in there.
70 lines
1.9 KiB
PHP
70 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin\Modules;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\UnzipUpdateRequest;
|
|
use App\Http\Requests\UploadModuleRequest;
|
|
use App\Support\Module\ModuleInstaller;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ModuleInstallationController extends Controller
|
|
{
|
|
public function download(Request $request): JsonResponse
|
|
{
|
|
$this->authorize('manage modules');
|
|
|
|
$response = ModuleInstaller::download(
|
|
(string) $request->slug,
|
|
(string) $request->version,
|
|
$request->checksum_sha256 ? (string) $request->checksum_sha256 : null,
|
|
);
|
|
|
|
return response()->json($response);
|
|
}
|
|
|
|
public function upload(UploadModuleRequest $request): JsonResponse
|
|
{
|
|
$this->authorize('manage modules');
|
|
|
|
$response = ModuleInstaller::upload($request);
|
|
|
|
return response()->json($response);
|
|
}
|
|
|
|
public function unzip(UnzipUpdateRequest $request): JsonResponse
|
|
{
|
|
$this->authorize('manage modules');
|
|
|
|
$path = ModuleInstaller::unzip($request->module_name ?? $request->module, $request->path);
|
|
|
|
return response()->json([
|
|
'success' => true,
|
|
'path' => $path,
|
|
]);
|
|
}
|
|
|
|
public function copy(Request $request): JsonResponse
|
|
{
|
|
$this->authorize('manage modules');
|
|
|
|
$response = ModuleInstaller::copyFiles($request->module_name ?? $request->module, $request->path);
|
|
|
|
return response()->json([
|
|
'success' => $response,
|
|
]);
|
|
}
|
|
|
|
public function complete(Request $request): JsonResponse
|
|
{
|
|
$this->authorize('manage modules');
|
|
|
|
$response = ModuleInstaller::complete($request->module_name ?? $request->module, $request->version);
|
|
|
|
return response()->json([
|
|
'success' => $response,
|
|
]);
|
|
}
|
|
}
|