Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
typemodel.php
1<?php
2
4
7
8class TypeModel implements AccessibleType
9{
10 private static array $cache = [];
11
12 private int $id = 0;
13 private string $xmlId = '';
14
15 public static function createFromId(int $itemId = 0): AccessibleItem
16 {
17 return new self();
18 }
19
20 public static function createFromXmlId(string $xmlId): AccessibleItem
21 {
22 if (!isset(static::$cache[$xmlId]))
23 {
24 $model = new self();
25 $model->setXmlId($xmlId);
26 static::$cache[$xmlId] = $model;
27 }
28
29 return static::$cache[$xmlId];
30 }
31
32 public static function createNew(): self
33 {
34 return new self();
35 }
36
37 public static function createFromSectionModel(SectionModel $sectionModel): self
38 {
39 if ($sectionModel->getType() !== '')
40 {
41 $model = self::createFromXmlId($sectionModel->getType());
42 }
43 else
44 {
45 $model = self::createNew();
46 }
47
48 return $model;
49 }
50
51 public function getId(): int
52 {
53 return $this->id;
54 }
55
56 public function setXmlId(string $xmlId): self
57 {
58 $this->xmlId = $xmlId;
59 return $this;
60 }
61
62 public function getXmlId(): string
63 {
64 return $this->xmlId;
65 }
66}
static createFromXmlId(string $xmlId)
Definition typemodel.php:20
static createFromSectionModel(SectionModel $sectionModel)
Definition typemodel.php:37
static createFromId(int $itemId=0)
Definition typemodel.php:15