Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
UrlCollection.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Entity\Url
;
4
5
use
Bitrix\Im\V2\Entity\EntityCollection
;
6
use
Bitrix\Main\UrlPreview\UrlPreview
;
7
12
class
UrlCollection
extends
EntityCollection
13
{
17
public
function
__construct
(?array $urls =
null
)
18
{
19
parent::__construct();
20
21
if
($urls !=
null
)
22
{
23
foreach
($urls as $url)
24
{
25
$this[] =
new
UrlItem
($url);
26
}
27
}
28
}
29
30
public
static
function
getRestEntityName
(): string
31
{
32
return
'urls'
;
33
}
34
39
public
static
function
initByPreviewUrlsIds
(array $previewUrlsIds,
bool
$withHtml =
true
): self
40
{
41
$urlCollection =
new
static
();
42
43
if
(empty($previewUrlsIds))
44
{
45
return
$urlCollection;
46
}
47
48
if
($withHtml)
49
{
50
$previews = UrlPreview::getMetadataAndHtmlByIds($previewUrlsIds);
51
}
52
else
53
{
54
$previews = UrlPreview::getMetadataByIds($previewUrlsIds);
55
}
56
57
if
($previews ===
false
)
58
{
59
return
$urlCollection;
60
}
61
62
foreach
($previews as $preview)
63
{
64
$urlCollection[] =
UrlItem::initByMetadata
($preview);
65
}
66
67
return
$urlCollection;
68
}
69
70
public
static
function
initByMessage
(\
Bitrix
\Im\V2\
Message
$message): self
71
{
72
$urls =
UrlItem::getUrlsFromText
($message->getMessage());
73
74
return
new
static
($urls);
75
}
76
}
Bitrix\Im\V2\Entity\EntityCollection
Definition
EntityCollection.php:13
Bitrix\Im\V2\Entity\Url\UrlCollection
Definition
UrlCollection.php:13
Bitrix\Im\V2\Entity\Url\UrlCollection\initByPreviewUrlsIds
static initByPreviewUrlsIds(array $previewUrlsIds, bool $withHtml=true)
Definition
UrlCollection.php:39
Bitrix\Im\V2\Entity\Url\UrlCollection\getRestEntityName
static getRestEntityName()
Definition
UrlCollection.php:30
Bitrix\Im\V2\Entity\Url\UrlCollection\initByMessage
static initByMessage(\Bitrix\Im\V2\Message $message)
Definition
UrlCollection.php:70
Bitrix\Im\V2\Entity\Url\UrlCollection\__construct
__construct(?array $urls=null)
Definition
UrlCollection.php:17
Bitrix\Im\V2\Entity\Url\UrlItem
Definition
UrlItem.php:14
Bitrix\Im\V2\Entity\Url\UrlItem\initByMetadata
static initByMetadata(array $metadata)
Definition
UrlItem.php:55
Bitrix\Im\V2\Entity\Url\UrlItem\getUrlsFromText
static getUrlsFromText(?string $text)
Definition
UrlItem.php:82
Bitrix\Im\V2\Message
Definition
Message.php:44
Bitrix\Main\UrlPreview\UrlPreview
Definition
urlpreview.php:18
Bitrix\Im\V2\Entity\Url
Definition
RichData.php:3
Bitrix
modules
im
lib
V2
Entity
Url
UrlCollection.php
Создано системой
1.10.0