Files
orderPRO/bin/cron.php
Jacek Pyziak 880ab5933f feat(02-bug-fixes): extract CronHandlerFactory, complete Phase 2
Phase 2 complete (4/4 plans):
- Plan 02-01: Fix dead ZPL page size condition in AllegroShipmentService
- Plan 02-02: Add time-based cursor to AllegroStatusSyncService
- Plan 02-03: Fix ShopproOrdersSyncService using wrong state repository
- Plan 02-04: Extract CronHandlerFactory as single cron composition point

Plan 02-04 specifics:
- New CronHandlerFactory builds complete cron object graph
- Application::maybeRunCronOnWeb() reduced from 80+ to ~20 lines
- bin/cron.php reduced from 123 to 26 lines
- Fixed 2 bugs: AllegroOAuthClient→AllegroTokenManager,
  AllegroOrderSyncStateRepository→ShopproOrderSyncStateRepository

Co-Authored-By: Claude <noreply@anthropic.com>
2026-03-13 00:43:04 +01:00

27 lines
774 B
PHP

<?php
declare(strict_types=1);
use App\Core\Application;
use App\Modules\Cron\CronHandlerFactory;
use App\Modules\Cron\CronRepository;
/** @var Application $app */
$app = require dirname(__DIR__) . '/bootstrap/app.php';
$limit = 20;
foreach (array_slice($argv, 1) as $arg) {
if (preg_match('/^--limit=(\d+)$/', (string) $arg, $matches) === 1) {
$limit = max(1, min(100, (int) ($matches[1] ?? 20)));
}
}
$cronRepository = new CronRepository($app->db());
$factory = new CronHandlerFactory(
$app->db(),
(string) $app->config('app.integrations.secret', '')
);
$runner = $factory->build($cronRepository, $app->logger());
$result = $runner->run($limit);
fwrite(STDOUT, json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL);