Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
UrlCollection.php
1<?php
2
4
7
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}
static initByPreviewUrlsIds(array $previewUrlsIds, bool $withHtml=true)
static initByMessage(\Bitrix\Im\V2\Message $message)
static initByMetadata(array $metadata)
Definition UrlItem.php:55
static getUrlsFromText(?string $text)
Definition UrlItem.php:82