1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
collabs.php
См. документацию.
1<?php
2
3namespace Bitrix\Calendar\Integration\SocialNetwork\Collab;
4
5use Bitrix\Calendar\Integration\SocialNetwork\AvatarService;
6use Bitrix\Main\Loader;
7use Bitrix\Main\ORM\Query\Filter\ConditionTree;
8use Bitrix\Socialnetwork\Collab\Collab;
9use Bitrix\Socialnetwork\Collab\Provider\CollabProvider;
10use Bitrix\Socialnetwork\Collab\Provider\CollabQuery;
11
12final class Collabs
13{
14 private static ?self $instance;
15
16 public static function getInstance(): self
17 {
18 self::$instance ??= new self();
19
20 return self::$instance;
21 }
22
23 public function getCollabIfExists(int $id): ?Collab
24 {
25 if (!$this->isAvailable())
26 {
27 return null;
28 }
29
30 try
31 {
32 return CollabProvider::getInstance()->getCollab($id);
33 }
34 catch (\Throwable)
35 {
36 return null;
37 }
38 }
39
44 public function getCollabIdsByGroupIds(array $ids): array
45 {
46 if (!$this->isAvailable())
47 {
48 return [];
49 }
50
51 $collabQuery = (new CollabQuery())
52 ->setWhere((new ConditionTree())->whereIn('ID', $ids))
53 ;
54
55 return array_map(
56 'intval',
57 CollabProvider::getInstance()->getList($collabQuery)->getIdList()
58 );
59 }
60
61 public function getById(int $id): ?Collab
62 {
63 if (!$this->isAvailable())
64 {
65 return null;
66 }
67
68 try
69 {
70 return (new CollabProvider())->getCollab($id);
71 }
72 catch (\Throwable)
73 {
74 return null;
75 }
76 }
77
78 public function getCollabImagePath(int $imageId): ?string
79 {
80 if (!$this->isAvailable())
81 {
82 return null;
83 }
84
85 return (new AvatarService())->getAvatar($imageId)->getId();
86 }
87
88 private function isAvailable(): bool
89 {
90 return Loader::includeModule('socialnetwork');
91 }
92
93 private function __construct()
94 {
95 }
96}
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804