Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
leadadsform.php
1<?php
2
3namespace Bitrix\Seo\LeadAds;
4
5
6use JsonSerializable;
7
8class LeadAdsForm implements JsonSerializable
9{
11 protected $id;
12
14 protected $name;
15
17 protected $description;
18
20 protected $title;
21
23 protected $fields;
24
26 protected $successMessage;
27
29 protected $link;
30
32 protected $active = true;
33
47 public function __construct(array $parameters = [])
48 {
49 if (array_key_exists('id',$parameters))
50 {
51 $this->id = $parameters['id'];
52 }
53 if (array_key_exists('name',$parameters) && is_string($parameters['name']))
54 {
55 $this->name = $parameters['name'];
56 }
57 if (array_key_exists('description',$parameters) && is_string($parameters['description']))
58 {
59 $this->description = $parameters['description'];
60 }
61 if (array_key_exists('title',$parameters) && is_string($parameters['title']))
62 {
63 $this->title = $parameters['title'];
64 }
65 if (array_key_exists('fields',$parameters) && is_array($parameters['fields']))
66 {
67 $this->fields = array_filter(
68 $parameters['fields'],
69 static function($object)
70 {
71 return $object instanceof Field && $object->getKey();
72 }
73 );
74 }
75 if (array_key_exists('message',$parameters) && is_string($parameters['message']))
76 {
77 $this->successMessage = $parameters['message'];
78 }
79 if (array_key_exists('link',$parameters) && is_string($parameters['link']))
80 {
81 $this->link = $parameters['link'];
82 }
83 if (array_key_exists('active', $parameters) && is_scalar($parameters['active']))
84 {
85 $this->active = (bool) $parameters['active'];
86 }
87 }
88
89 public function getId()
90 {
91 return $this->id;
92 }
93
97 public function getName() : ?string
98 {
99 return $this->name;
100 }
101
105 public function getDescription() : ?string
106 {
107 return $this->description;
108 }
109
113 public function getTitle() : ?string
114 {
115 return $this->title;
116 }
117
121 public function getFields() : ?array
122 {
123 return $this->fields;
124 }
125
129 public function getSuccessMessage() : ?string
130 {
132 }
133
137 public function getLink() : ?string
138 {
139 return $this->link;
140 }
141
145 public function isActive() : bool
146 {
147 return $this->active;
148 }
149
153 public function toArray(): array
154 {
155 return array_filter([
156 'id' => $this->id,
157 'name' => $this->name,
158 'title' => $this->title,
159 'description' => $this->description,
160 'message' => $this->successMessage,
161 'link' => $this->link,
162 'active' => $this->active,
163 'fields' => array_map(
164 static function(Field $element) : array
165 {
166 return $element->toArray();
167 },
169 )
170 ]);
171 }
172
176 public function jsonSerialize()
177 {
178 return $this->toArray();
179 }
180}
__construct(array $parameters=[])