403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/calendar/lib/core/mappers/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/calendar/lib/core/mappers/eventoption.php
<?php

namespace Bitrix\Calendar\Core\Mappers;

use Bitrix\Calendar\Core;
use Bitrix\Calendar\Core\Base\EntityInterface;
use Bitrix\Calendar\Core\Builders\EventOption\EventOptionBuilderFromObject;
use Bitrix\Calendar\OpenEvents\Internals\OpenEventOptionTable;
use Bitrix\Main\ORM\Query\Result;

final class EventOption extends Mapper
{
	protected function getEntityClass(): string
	{
		return Core\eventoption\EventOption::class;
	}

	protected function getDataManagerResult(array $params): Result
	{
		$params['select'] = $params['select'] ?? ["*"];

		return OpenEventOptionTable::getList($params);
	}

	protected function getOneEntityByFilter(array $filter): ?object
	{
		$eventData = OpenEventOptionTable::query()
			->setFilter($filter)
			->setSelect(['*'])
			->fetchObject();

		if ($eventData)
		{
			return $this->convertToObject($eventData);
		}

		return null;
	}

	protected function convertToObject($objectEO): ?EntityInterface
	{
		return (new EventOptionBuilderFromObject($objectEO))->build();
	}

	protected function getEntityName(): string
	{
		return 'event_option';
	}

	protected function createEntity($entity, array $params = []): ?EntityInterface
	{
		$arrayEntity = $this->entityToArray($entity);
		$result = OpenEventOptionTable::add($arrayEntity);

		if ($result->isSuccess())
		{
			$entity->setId($result->getId());

			return $entity;
		}

		throw new Core\Base\BaseException('Error of create event option');
	}

	/**
	 * @param Core\EventOption\EventOption $entity
	 */
	protected function updateEntity($entity, array $params = [
		'updateAttendeesCounter' => false,
	]): ?EntityInterface
	{
		$arrayEntity = $this->entityToArray($entity);

		if ($params['updateAttendeesCounter'] ?? null)
		{
			$arrayEntity['ATTENDEES_COUNT'] = $entity->getAttendeesCount();
		}

		$result = OpenEventOptionTable::update(
			$entity->getId(),
			$arrayEntity
		);

		if ($result->isSuccess())
		{
			return $entity;
		}

		throw new Core\Base\BaseException('Error of update event option');
	}

	protected function deleteEntity(EntityInterface $entity, array $params): ?EntityInterface
	{
		throw new Core\Base\BaseException('Delete of event option not implemented');
	}

	private function entityToArray($entity): array
	{
		return [
			'EVENT_ID' => $entity->getEventId(),
			'CATEGORY_ID' => $entity->getCategoryId(),
			'THREAD_ID' => $entity->getThreadId(),
			'OPTIONS' => json_encode($entity->getOptions()),
		];
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit