Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
channel.php
1
<?php
2
3
namespace
Bitrix\Pull\Model
;
4
5
use
Bitrix\Main\SystemException
;
6
use
Bitrix\Main\Type\DateTime
;
7
8
class
Channel
9
{
10
protected
$id
;
11
protected
$userId
;
12
protected
$privateId
;
13
protected
$publicId
;
14
protected
$type
= \CPullChannel::TYPE_PRIVATE;
15
protected
$dateCreate
;
16
17
public
static
function
createWithTag
(
string
$tag):
Channel
18
{
19
$instance =
new
static
();
20
$instance->privateId = \CPullChannel::GetNewChannelIdByTag($tag);
21
$instance->publicId = \CPullChannel::GetNewChannelIdByTag($tag,
'public'
);
22
$instance->dateCreate =
new
DateTime
();
23
24
return
$instance;
25
}
26
27
public
static
function
createRandom
():
Channel
28
{
29
$instance =
new
static
();
30
$instance->privateId = \CPullChannel::GetNewChannelId();
31
$instance->publicId = \CPullChannel::GetNewChannelId(
'public'
);
32
$instance->dateCreate =
new
DateTime
();
33
34
return
$instance;
35
}
36
42
public
static
function
getShared
():
Channel
43
{
44
$fields = \CPullChannel::GetShared();
45
if
(!$fields)
46
{
47
throw
new
SystemException
(
"Public channel is empty"
);
48
}
49
50
return
static::createWithFields($fields);
51
}
52
53
public
static
function
createWithFields
(array $fields):
Channel
54
{
55
$instance =
new
static
();
56
if
(isset($fields[
'CHANNEL_ID'
]))
57
{
58
$instance->privateId = $fields[
'CHANNEL_ID'
];
59
}
60
if
(isset($fields[
'CHANNEL_PUBLIC_ID'
]))
61
{
62
$instance->publicId = $fields[
'CHANNEL_PUBLIC_ID'
];
63
}
64
if
(isset($fields[
'CHANNEL_TYPE'
]))
65
{
66
$instance->type = $fields[
'CHANNEL_TYPE'
];
67
}
68
if
(isset($fields[
'CHANNEL_DT'
]))
69
{
70
$instance->dateCreate =
DateTime::createFromTimestamp
($fields[
'CHANNEL_DT'
]);
71
}
72
73
return
$instance;
74
}
75
76
public
function
getId
(): ?int
77
{
78
return
$this->id
;
79
}
80
81
public
function
getUserId
(): ?int
82
{
83
return
$this->userId
;
84
}
85
86
public
function
getPrivateId
(): string
87
{
88
return
$this->privateId
;
89
}
90
91
public
function
getPublicId
(): string
92
{
93
return
$this->publicId
;
94
}
95
96
public
function
getSignedPublicId
(): string
97
{
98
return \CPullChannel::SignPublicChannel($this->publicId);
99
}
100
101
public
function
getType
(): string
102
{
103
return
$this->type
;
104
}
105
106
public
function
getDateCreate
():
DateTime
107
{
108
return
$this->dateCreate
;
109
}
110
}
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Type\DateTime\createFromTimestamp
static createFromTimestamp($timestamp)
Definition
datetime.php:246
Bitrix\Pull\Model\Channel
Definition
channel.php:9
Bitrix\Pull\Model\Channel\getUserId
getUserId()
Definition
channel.php:81
Bitrix\Pull\Model\Channel\getId
getId()
Definition
channel.php:76
Bitrix\Pull\Model\Channel\getShared
static getShared()
Definition
channel.php:42
Bitrix\Pull\Model\Channel\getDateCreate
getDateCreate()
Definition
channel.php:106
Bitrix\Pull\Model\Channel\getSignedPublicId
getSignedPublicId()
Definition
channel.php:96
Bitrix\Pull\Model\Channel\createWithFields
static createWithFields(array $fields)
Definition
channel.php:53
Bitrix\Pull\Model\Channel\$publicId
$publicId
Definition
channel.php:13
Bitrix\Pull\Model\Channel\createRandom
static createRandom()
Definition
channel.php:27
Bitrix\Pull\Model\Channel\getType
getType()
Definition
channel.php:101
Bitrix\Pull\Model\Channel\$userId
$userId
Definition
channel.php:11
Bitrix\Pull\Model\Channel\$type
$type
Definition
channel.php:14
Bitrix\Pull\Model\Channel\$privateId
$privateId
Definition
channel.php:12
Bitrix\Pull\Model\Channel\$dateCreate
$dateCreate
Definition
channel.php:15
Bitrix\Pull\Model\Channel\createWithTag
static createWithTag(string $tag)
Definition
channel.php:17
Bitrix\Pull\Model\Channel\getPublicId
getPublicId()
Definition
channel.php:91
Bitrix\Pull\Model\Channel\getPrivateId
getPrivateId()
Definition
channel.php:86
Bitrix\Pull\Model\Channel\$id
$id
Definition
channel.php:10
Bitrix\Pull\Model
Definition
channel.php:3
modules
pull
lib
model
channel.php
Создано системой
1.10.0