Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
socnetgroup.php
1<?php
10
11
15
17{
18 private static $modelsCache = [];
19
20 public function getType(): string
21 {
22 return AccessCode::TYPE_SOCNETGROUP;
23 }
24
25 public function getName(): string
26 {
27 if ($this->model)
28 {
29 return $this->model->getName();
30 }
31 return '';
32 }
33
34 public function getUrl(): string
35 {
36 $groupUrlTemplate = \COption::GetOptionString("socialnetwork", "group_path_template", "/workgroups/group/#group_id#/", SITE_ID);
37 return str_replace(array("#group_id#", "#GROUP_ID#"), $this->getId(), $groupUrlTemplate);
38 }
39
40 public function getAvatar(int $width = 58, int $height = 58): ?string
41 {
42 if ($this->model)
43 {
44 $arFile = \CFile::GetFileArray($this->model->getImageId());
45 if(is_array($arFile))
46 {
47 return $arFile['SRC'];
48 }
49 }
50 return '';
51 }
52
53 protected function loadModel()
54 {
55 if (!$this->model)
56 {
57 if (array_key_exists($this->id, self::$modelsCache))
58 {
59 $this->model = self::$modelsCache[$this->id];
60 }
61 else
62 {
63 $this->model = WorkgroupTable::getList([
64 'select' => [
65 'ID',
66 'NAME',
67 'IMAGE_ID',
68 ],
69 'filter' => [
70 '=ID' => $this->id,
71 ],
72 'limit' => 1,
73 ])->fetchObject();
74
75 self::$modelsCache[$this->id] = $this->model;
76 }
77 }
78 }
79}
getAvatar(int $width=58, int $height=58)