3namespace Bitrix\Calendar\Sync\Factories;
5use Bitrix\Calendar\Core;
6use Bitrix\Calendar\Core\Base\BaseException;
7use Bitrix\Calendar\Core\Builders\SectionBuilderFromDataManager;
8use Bitrix\Calendar\Core\Section\Section;
9use Bitrix\Calendar\Internals\EO_Section;
10use Bitrix\Calendar\Internals\SectionConnectionTable;
11use Bitrix\Calendar\Sync\Connection\Connection;
12use Bitrix\Calendar\Internals\EO_SectionConnection;
13use Bitrix\Calendar\Sync\Connection\SectionConnection;
14use Bitrix\Main\ArgumentException;
15use Bitrix\Main\DI\ServiceLocator;
16use Bitrix\Main\ObjectPropertyException;
17use Bitrix\Main\SystemException;
22 private $mapperFactory;
25 $this->mapperFactory = ServiceLocator::getInstance()->get(
'calendar.service.mappers.factory');
40 $statement = SectionConnectionTable::query()->setSelect([
'*']);
43 $statement->setFilter(
$params[
'filter']);
45 if ($link = $statement->fetchObject())
48 return $this->prepareLink(
50 $params[
'connectionObject'] ??
null,
51 $params[
'sectionObject'] ??
null,
75 $linkData = SectionConnectionTable::query()
78 ->addFilter(
'SECTION_ID', $section->getId())
79 ->exec()->fetchObject()
86 return $this->prepareLink($linkData,
$connection, $section);
101 $statement = SectionConnectionTable::query();
102 $statement->setSelect([
'*']);
103 $statement->addFilter(
'CONNECTION_ID',
$connection->getId());
106 $statement->addFilter(
'=ACTIVE',
'Y');
109 $links = $statement->exec();
111 while ($link = $links->fetchObject())
131 private function prepareLink(
139 $connection = $this->mapperFactory->getConnection()->getById($link->getConnectionId());
142 ?? ($link->getSection()
143 ? $this->buildSection($link->getSection())
146 if ($section ===
null)
148 $section = $this->mapperFactory->getSection()->getById($link->getSectionId());
152 throw new BaseException(
'Section not found');
157 $item =
new SectionConnection();
159 ->setId($link->getId())
160 ->setSection($section)
162 ->setVendorSectionId($link->getVendorSectionId())
163 ->setSyncToken($link->getSyncToken())
164 ->setPageToken($link->getPageToken())
165 ->setActive($link->getActive())
166 ->setLastSyncDate(
new Core\Base\Date($link->getLastSyncDate()))
167 ->setLastSyncStatus($link->getLastSyncStatus())
168 ->setVersionId($link->get(
'VERSION_ID'))
179 private function buildSection(EO_Section $EOSection): Section
181 return (
new SectionBuilderFromDataManager($EOSection))->build();
getListByConnection(Connection $connection, bool $onlyActive=true)
getSectionConnection(array $params)
getFromSectionConnection(Section $section, Connection $connection)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']