Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
content.php
1<?php
2
4
6
7class Content
8{
9 private $type;
10 private $properties = [];
11 private $subComponents = [];
12
13 public static function getInstance(string $type): Content
14 {
15 return new self($type);
16 }
17
18 public function __construct(string $type)
19 {
20 $this->type = $type;
21 }
22
23 public function property(PropertyType $property, array $parameters = null): Content
24 {
25 $property->addParameters($parameters ?? []);
26
27 $this->properties[] = $property;
28
29 return $this;
30 }
31
32 public function dateTimeProperty(
33 $names,
34 Date $value,
35 bool $withTime = false,
36 bool $withTimeZone = false,
37 bool $isUTC = false
38 ): Content
39 {
40 if ($value === null)
41 {
42 return $this;
43 }
44
45 return $this->property(new DateTimePropertyType($names, $value, $withTime, $withTimeZone, $isUTC));
46 }
47
48 public function textProperty($names, ?string $value, bool $disableEscaping = false) : Content
49 {
50 if ($value === null) {
51 return $this;
52 }
53
54 return $this->property(new TextPropertyType($names, $value, $disableEscaping));
55 }
56
57 public function timezoneOffsetProperty(
58 $names,
59 \DateTimeZone $value
60 ): Content
61 {
62 if ($value === null)
63 {
64 return $this;
65 }
66
67 return $this->property(new DateTimePropertyType($names, $value));
68 }
69
70 public function subComponent(BasicComponent ...$components) : Content
71 {
72 foreach ($components as $component)
73 {
74 $this->subComponents[] = $component;
75 }
76
77 return $this;
78 }
79
80 public function getType() : string
81 {
82 return $this->type;
83 }
84
85 public function getProperties() : array
86 {
87 return $this->properties;
88 }
89
90 public function getSubComponents() : array
91 {
92 return $this->subComponents;
93 }
94}
static getInstance(string $type)
Definition content.php:13
timezoneOffsetProperty( $names, \DateTimeZone $value)
Definition content.php:57
subComponent(BasicComponent ... $components)
Definition content.php:70
textProperty($names, ?string $value, bool $disableEscaping=false)
Definition content.php:48
dateTimeProperty( $names, Date $value, bool $withTime=false, bool $withTimeZone=false, bool $isUTC=false)
Definition content.php:32
property(PropertyType $property, array $parameters=null)
Definition content.php:23