35 'NAME' => $section->getName(),
36 'ACTIVE' => $section->isActive() ? self::POSITIVE_ANSWER : self::NEGATIVE_ANSWER,
37 'DESCRIPTION' => $section->getDescription(),
38 'COLOR' => $section->getColor(),
39 'TEXT_COLOR' => $section->getTextColor(),
40 'SORT' => $section->getSort() ?? self::DEFAULT_SORT,
41 'CAL_TYPE' => $section->getType(),
42 'OWNER_ID' => !$section->getOwner() ?: $section->getOwner()->getId(),
44 'XML_ID' => $section->getXmlId(),
45 'EXTERNAL_ID' => $section->getExternalId(),
46 'GAPI_CALENDAR_ID' => $section->getGoogleId(),
47 'EXPORT' => $section->getExport(),
48 'CREATED_BY' => !$section->getCreator() ?: $section->getCreator()->getId(),
49 'PARENT_ID' => $section->getParentId(),
51 'DAV_EXCH_CAL' => $section->getDavExchangeCal(),
52 'DAV_EXCH_MOD' => $section->getDavExchangeMod(),
53 'CAL_DAV_CON' => $section->getCalDavConnectionId(),
54 'CAL_DAV_CAL' => $section->getCalDavCal(),
55 'CAL_DAV_MOD' => $section->getCalDavMod(),
56 'IS_EXCHANGE' => $section->isExchange() ? 1 : 0,
57 'SYNC_TOKEN' => $section->getSyncToken(),
58 'EXTERNAL_TYPE' => $section->getExternalType(),
59 'PAGE_TOKEN' => $section->getPageToken(),
74 $sectionData = SectionTable::query()
117 $arrayEntity = $this->prepareArrayEntityForDB(
$entity);
119 $result = SectionTable::add($arrayEntity);
123 $this->sendPushEdit(
$entity->getOwner()->getId(),
true);
144 $arrayEntity = $this->prepareArrayEntityForDB(
$entity);
146 $result = SectionTable::update(
153 $this->sendPushEdit(
$entity->getOwner()->getId(),
false);
165 return Core\Section\SectionMap::class;
181 if (!empty(
$params[
'softDelete']))
208 return SectionTable::getList(
$params);
218 private function saveXmlId(
int $id,
string $type): string
220 $xmlId = md5(
$type.
'_'. $id.
'_'. Random::getString(8));
222 SectionTable::update($id, [
234 private function sendPushEdit(
int $userId,
bool $isNewSection): void
237 PushCommand::EditSection,
240 'newSection' => $isNewSection,
250 private function prepareArrayEntityForDB(
$entity):
array
252 $arrayEntity = $this->convertToArray(
$entity);
253 if (!empty($arrayEntity[
'NAME']))
255 $arrayEntity[
'NAME'] = Emoji::encode($arrayEntity[
'NAME']);
266 return Core\Section\Section::class;