instances added god may help

This commit is contained in:
2026-02-23 12:58:19 +01:00
parent 25370a1a55
commit 99db252f60
290 changed files with 9858 additions and 4914 deletions

View File

@@ -8,7 +8,7 @@ interface ScheduledJobHandlerInterface
* Returns the job definition (metadata + schedule defaults).
*
* The job_key is NOT included here it is provided as the key in the
* registry handler map (ScheduledJobRegistry::handlers()).
* registry handler map in ScheduledJobRegistry.
*
* Required keys:
* label (string) Human-readable name shown in admin UI.
@@ -22,7 +22,7 @@ interface ScheduledJobHandlerInterface
* default_catchup_once (int) 1 = catch up once after downtime (default).
* allowed_schedule_types (array) Subset of ['hourly','daily','weekly'].
*/
public static function definition(): array;
public function definition(): array;
/**
* Executes the job and returns a normalized result envelope.
@@ -42,5 +42,5 @@ interface ScheduledJobHandlerInterface
* error_message: human-readable detail, null on success (max 255 chars)
* result: job-specific payload, empty array if nothing to report
*/
public static function execute(?int $actorUserId): array;
public function execute(?int $actorUserId): array;
}

View File

@@ -6,7 +6,11 @@ use MintyPHP\Service\User\UserLifecycleService;
class UserLifecycleJobHandler implements ScheduledJobHandlerInterface
{
public static function definition(): array
public function __construct(private readonly UserLifecycleService $userLifecycleService)
{
}
public function definition(): array
{
return [
'label' => 'User lifecycle run',
@@ -22,9 +26,9 @@ class UserLifecycleJobHandler implements ScheduledJobHandlerInterface
];
}
public static function execute(?int $actorUserId): array
public function execute(?int $actorUserId): array
{
$result = UserLifecycleService::run($actorUserId !== null && $actorUserId > 0 ? $actorUserId : null);
$result = $this->userLifecycleService->run($actorUserId !== null && $actorUserId > 0 ? $actorUserId : null);
if (!($result['ok'] ?? false)) {
$errorCode = (string) ($result['error'] ?? 'job_failed');
@@ -33,7 +37,7 @@ class UserLifecycleJobHandler implements ScheduledJobHandlerInterface
'status' => $status,
'error_code' => $errorCode,
'error_message' => null,
'result' => self::formatResult($result),
'result' => $this->formatResult($result),
];
}
@@ -41,11 +45,11 @@ class UserLifecycleJobHandler implements ScheduledJobHandlerInterface
'status' => 'success',
'error_code' => null,
'error_message' => null,
'result' => self::formatResult($result),
'result' => $this->formatResult($result),
];
}
private static function formatResult(array $result): array
private function formatResult(array $result): array
{
return [
'run_uuid' => (string) ($result['run_uuid'] ?? ''),