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/pull/lib/model/ |
Upload File : |
<?php namespace Bitrix\Pull\Model; use Bitrix\Main\SystemException; use Bitrix\Main\Type\DateTime; class Channel { protected $id; protected $userId; protected $privateId; protected $publicId; protected $type = \CPullChannel::TYPE_PRIVATE; protected $dateCreate; public static function createWithTag(string $tag): Channel { $instance = new static(); $instance->privateId = \CPullChannel::GetNewChannelIdByTag($tag); $instance->publicId = \CPullChannel::GetNewChannelIdByTag($tag,'public'); $instance->dateCreate = new DateTime(); return $instance; } public static function createRandom(): Channel { $instance = new static(); $instance->privateId = \CPullChannel::GetNewChannelId(); $instance->publicId = \CPullChannel::GetNewChannelId('public'); $instance->dateCreate = new DateTime(); return $instance; } /** * Returns Channel instance, suitable for sending to the shared channel. * @return Channel * @throws SystemException */ public static function getShared(): Channel { $fields = \CPullChannel::GetShared(); if (!$fields) { throw new SystemException("Public channel is empty"); } return static::createWithFields($fields); } public static function createWithFields(array $fields): Channel { $instance = new static(); if (isset($fields['CHANNEL_ID'])) { $instance->privateId = $fields['CHANNEL_ID']; } if (isset($fields['CHANNEL_PUBLIC_ID'])) { $instance->publicId = $fields['CHANNEL_PUBLIC_ID']; } if (isset($fields['CHANNEL_TYPE'])) { $instance->type = $fields['CHANNEL_TYPE']; } if (isset($fields['CHANNEL_DT'])) { $instance->dateCreate = DateTime::createFromTimestamp($fields['CHANNEL_DT']); } return $instance; } public function getId(): ?int { return $this->id; } public function getUserId(): ?int { return $this->userId; } public function getPrivateId(): string { return $this->privateId; } public function getPublicId(): string { return $this->publicId; } public function getSignedPublicId(): string { return \CPullChannel::SignPublicChannel($this->publicId); } public function getType(): string { return $this->type; } public function getDateCreate(): DateTime { return $this->dateCreate; } }