1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
buildersyncsectionfromexternaldata.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Google\Builders;
4
5use Bitrix\Calendar\Core\Base\Date;
6use Bitrix\Calendar\Core\Builders\Builder;
7use Bitrix\Calendar\Core\Section\Section;
8use Bitrix\Calendar\Core\User\Creator;
9use Bitrix\Calendar\Core;
10use Bitrix\Calendar\Sync\Connection\Connection;
11use Bitrix\Calendar\Sync\Connection\SectionConnection;
12use Bitrix\Calendar\Sync\Dictionary;
13use Bitrix\Calendar\Sync\Google;
14use Bitrix\Calendar\Sync\Entities\SyncSection;
15use Bitrix\Calendar\Sync\Google\Factory;
16
18{
19 private array $item;
20 private Connection $connection;
21
22 public function __construct(array $item, Connection $connection)
23 {
24 $this->item = $item;
25 $this->connection = $connection;
26 }
27
32 public function build()
33 {
34 if ($this->connection->getOwner() === null)
35 {
36 throw new Core\Base\BaseException('The connection must have an owner');
37 }
38
39 $section = (new Section())
40 ->setName($this->item['summary'])
41 ->setColor($this->item['backgroundColor'])
42 ->setOwner($this->connection->getOwner())
43 ->setCreator($this->connection->getOwner())
44 ->setExternalType(Google\Dictionary::ACCESS_ROLE_TO_EXTERNAL_TYPE[$this->item['accessRole']])
45 ->setType(Core\Event\Tools\Dictionary::CALENDAR_TYPE[Core\Role\User::TYPE])
46 ->setIsActive(true)
47 ->setDescription($this->item['description'] ?? null)
48 ;
49
50 $sectionConnection = (new SectionConnection())
51 ->setVendorSectionId($this->item['id'])
52 ->setActive(true)
53 ->setLastSyncDate(null)
54 ->setPrimary($this->item['primary'] ?? false)
55 ->setSection($section)
56 ->setOwner($this->connection->getOwner())
57 ->setLastSyncStatus(Dictionary::SYNC_STATUS['success'])
58 ->setConnection($this->connection)
59 ->setVersionId($this->item['etag'])
60 ;
61
62 $syncSection = (new SyncSection())
63 ->setSection($section)
64 ->setSectionConnection($sectionConnection)
65 ->setVendorName(Factory::SERVICE_NAME)
66 ;
67
68 if (!empty($this->item['deleted']))
69 {
70 $syncSection->setAction(Dictionary::SYNC_SECTION_ACTION['delete']);
71 }
72 else
73 {
74 $syncSection->setAction(Dictionary::SYNC_SECTION_ACTION['success']);
75 }
76
77 return $syncSection;
78 }
79}
const SYNC_SECTION_ACTION
Определения dictionary.php:40
const SYNC_STATUS
Определения dictionary.php:16
const ACCESS_ROLE_TO_EXTERNAL_TYPE
Определения dictionary.php:8
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804