16 private const OFFSET_INTERVAL_IN_SECONDS = 5;
17 private const MODULE_ID =
'im';
18 private const ENABLE_OPTION_NAME =
'sync_logger_enable';
22 return Option::get(self::MODULE_ID, self::ENABLE_OPTION_NAME,
'Y') ===
'Y';
27 if (!self::isEnable())
32 $date = $this->getDateWithOffset($date);
33 $logCollection = LogTable::query()
35 ->where(
'USER_ID', $this->getContext()->getUserId())
36 ->where(
'DATE_CREATE',
'>=', $date)
40 $logCollection->fill();
43 return $this->formatData($logCollection, $limit);
48 if (!self::isEnable())
53 $query = LogTable::query()
55 ->where(
'USER_ID', $this->getContext()->getUserId())
61 $query->where(
'ID',
'>', $id)->setOrder([
'ID' =>
'ASC']);
65 $query->setOrder([
'ID' =>
'DESC']);
68 $logCollection = $query->fetchCollection();
69 $logCollection->fill();
72 return $this->formatData($logCollection, $limit);
77 $offset = self::OFFSET_INTERVAL_IN_SECONDS;
78 $date->
add(
"- {$offset} seconds");
88 private function formatData(EO_Log_Collection $logCollection,
int $limit): array
93 foreach ($entities as $entity)
95 foreach ($entity->getData() as $name => $datum)
97 $data[$name] = $datum;
101 $data[
'hasMore'] = $logCollection->count() >= $limit;
102 $ids = $logCollection->getIdList();
105 $data[
'lastId'] = max($ids);