namespace PatreonSync\ScheduledTask; use Shopware\Core\Framework\Context; use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository; use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler; use PatreonSync\Service\PatreonSyncService; class PatreonSyncTaskHandler extends ScheduledTaskHandler { protected static string $taskClass = PatreonSyncTask::class; private EntityRepository $patreonLinkRepo; private PatreonSyncService $syncService; public function __construct( EntityRepository $scheduledTaskRepository, EntityRepository $patreonLinkRepo, PatreonSyncService $syncService ) { parent::__construct($scheduledTaskRepository); $this->patreonLinkRepo = $patreonLinkRepo; $this->syncService = $syncService; } public function run(): void { $context = Context::createDefaultContext(); $links = $this->patreonLinkRepo->search(new \Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria(), $context); foreach ($links->getElements() as $link) { $this->syncService->syncCustomer($link->getCustomerId(), [ 'user_id' => $link->getPatreonUserId(), 'access_token' => $link->getAccessToken(), 'refresh_token' => $link->getRefreshToken(), 'tier' => $link->getCurrentTier(), // Optional: live abrufen ], $context); } } }