drsApi = $drsApi; $this->logger = $logger; } public static function getType(): string { return static::$type; } public function setMode(int $mode): void { $this->mode = $mode; } public function process(): void { foreach ($this->getItems() as $item) { $this->logItem($item); $this->processItem($item); } } abstract protected function processItem(array $item): void; protected function getItems(): iterable { return []; } protected function getLastTimestamp(): ?int { if ($this->mode === self::MODE_FULL) { return null; } $dbcfg = \Settings::getDefault(); $drs = $dbcfg->loadValue('drs'); return $drs[static::getType()]['timestamp'] ?? null; } protected function setLastTimestamp(int $timestamp): void { $dbcfg = \Settings::getDefault(); $drs = $dbcfg->loadValue('drs') ?? []; $drs[static::getType()]['timestamp'] = $timestamp; $drs[static::getType()]['updated'] = time(); $dbcfg->saveValue('drs', $drs, false); } private function logItem(array $item): void { if (isDevelopment()) { return; } if (!$this->logging) { return; } $this->logger->log( sprintf('[pompo] Processing item of type "%s"', static::getType()), [ 'type' => static::getType(), 'data' => $item, ] ); } }