1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
servicesynchronization.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Sync\Managers;
4
5use Bitrix\Calendar\Core\Event\Event;
6use Bitrix\Calendar\Core\Handlers\HandlerBase;
7use Bitrix\Calendar\Core\Section\Section;
8use Bitrix\Calendar\Rooms\Util;
9use Bitrix\Calendar\Sync\Connection\SectionConnectionMap;
10use Bitrix\Calendar\Sync\Factories\FactoryInterface;
11use Bitrix\Calendar\Sync\Util\Context;
12use Bitrix\Calendar\Sync\Util\EventContext;
13use Bitrix\Main\Result;
14
19{
23 private $factory;
24
28 public function __construct(FactoryInterface $factory)
29 {
30 $this->factory = $factory;
31 }
32
41 {
42 $manager = $this->factory->getEventManager();
43 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection());
44 $actionResult = $manager->create($event, $eventContext);
45
46 return $this->handleResult($actionResult);
47 }
48
58 {
59 $manager = $this->factory->getEventManager();
60 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection(), $event);
61 $actionResult = $manager->update($event, $eventContext);
62
63 return $this->handleResult($actionResult);
64 }
65
67 {
68 $manager = $this->factory->getEventManager();
69 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection());
70 $actionResult = $manager->delete($event, $eventContext);
71
72 return $this->handleResult($actionResult);
73 }
74
76 {
77 $manager = $this->factory->getEventManager();
78 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection());
79 $actionResult = $manager->createInstance($event, $eventContext);
80
81 return $this->handleResult($actionResult);
82 }
83
85 {
86 $manager = $this->factory->getEventManager();
87 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection());
88 $actionResult = $manager->updateInstance($event, $eventContext);
89
90 return $this->handleResult($actionResult);
91 }
92
94 {
95 $manager = $this->factory->getEventManager();
96 $eventContext = $this->prepareEventContextFromContext($context, $event->getSection());
97 $actionResult = $manager->deleteInstance($event, $eventContext);
98
99 return $this->handleResult($actionResult);
100 }
101
102 public function createSection(Section $section): Result
103 {
104 $manager = $this->factory->getSectionManager();
105 $manager->create($section);
106
107 return new Result();
108 }
109
110 public function updateSection(Section $section): Result
111 {
112 $manager = $this->factory->getSectionManager();
113 $manager->update($section);
114
115 return new Result();
116 }
117
118 public function deleteSection(Section $section): Result
119 {
120 $manager = $this->factory->getSectionManager();
121 $manager->delete($section);
122
123 return new Result();
124 }
125
132 private function prepareEventContextFromContext(Context $context, Section $eventSection, Event $event = null): EventContext
133 {
134 $eventContext = new EventContext();
136 $sectionConnectionMap = $context->sectionConnections;
137 $sectionConnection = $sectionConnectionMap->getItem($eventSection->getId());
138
139 if ($event)
140 {
141 if (isset($context->eventConnections))
142 {
143 $eventContext->setEventConnection($context->eventConnections->getItem($event->getId()));
144 }
145
146 if ($location = $event->getLocation())
147 {
148 $eventContext->location = Util::getTextLocation((string)$location);
149 }
150 }
151
152 $eventContext->setSectionConnection($sectionConnection);
153
154 return $eventContext;
155 }
156
161 public function handleResult(Result $actionResult): Result
162 {
163 $result = new Result();
164 if ($actionResult->isSuccess())
165 {
166 $result->setData($actionResult->getData());
167 }
168 else
169 {
170 $result->addErrors(
171 $this->factory->handleErrors(
173 $actionResult->getErrorCollection()
174 )
175 );
176 }
177
178 return $result;
179 }
180}
updateEvent(Event $event, EventContext $context)
Определения servicesynchronization.php:57
createEvent(Event $event, Context $context)
Определения servicesynchronization.php:40
updateInstance(Event $event, EventContext $context)
Определения servicesynchronization.php:84
deleteInstance(Event $event, EventContext $context)
Определения servicesynchronization.php:93
createInstance(Event $event, EventContext $context)
Определения servicesynchronization.php:75
deleteEvent(Event $event, EventContext $context)
Определения servicesynchronization.php:66
isSuccess($internalCall=false)
Определения result.php:47
getData()
Определения result.php:148
getErrorCollection()
Определения result.php:87
$result
Определения get_property_values.php:14
$context
Определения csv_new_setup.php:223
Определения culture.php:9
$manager
Определения office365push.php:39
$event
Определения prolog_after.php:141
$location
Определения options.php:2729