Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
resultitem.php
1
<?php
2
3
namespace
Bitrix\Main\Search
;
4
5
use
Bitrix\Main\NotSupportedException
;
6
use
Bitrix\Main\Web\Uri
;
7
8
final
class
ResultItem
implements
\JsonSerializable, \ArrayAccess
9
{
11
private
$id;
13
private
$type;
15
private
$title;
17
private
$showLink;
19
private
$module;
21
private
$subTitle;
23
private
$actions = [];
25
private
$links = [];
27
private
$attributes = [];
28
36
public
function
__construct
($title, $showLink, $id =
null
)
37
{
38
$this
39
->setTitle($title)
40
->setShowLink($showLink)
41
->setId($id)
42
;
43
}
44
50
public
function
getId
()
51
{
52
return
$this->id;
53
}
54
61
public
function
setId
($id)
62
{
63
$this->
id
= $id;
64
65
return
$this;
66
}
67
74
public
function
getType
()
75
{
76
return
$this->type;
77
}
78
86
public
function
setType
($type)
87
{
88
$this->type = $type;
89
90
return
$this;
91
}
92
98
public
function
getTitle
()
99
{
100
return
$this->title;
101
}
102
109
public
function
setTitle
($title)
110
{
111
$this->title = $title;
112
113
return
$this;
114
}
115
121
public
function
getShowLink
()
122
{
123
return
$this->showLink;
124
}
125
132
public
function
setShowLink
($showLink)
133
{
134
$this->showLink = $this->
adjustLink
($showLink);
135
$this->
addLink
(
'show'
, $this->showLink);
136
137
return
$this;
138
}
139
146
protected
function
adjustLink
($link)
147
{
148
if
($link instanceof
Uri
)
149
{
150
return
$link;
151
}
152
153
return
new
Uri
($link);
154
}
155
161
public
function
getModule
()
162
{
163
return
$this->module;
164
}
165
173
public
function
setModule
($module)
174
{
175
$this->module = $module;
176
177
return
$this;
178
}
179
186
public
function
getSubTitle
()
187
{
188
return
$this->subTitle;
189
}
190
198
public
function
setSubTitle
($subTitle)
199
{
200
$this->subTitle = $subTitle;
201
202
return
$this;
203
}
204
210
public
function
getActions
()
211
{
212
return
$this->actions;
213
}
214
220
public
function
getLinks
()
221
{
222
return
$this->links;
223
}
224
232
public
function
setLinks
(array $links)
233
{
234
$adjustedLinks = [];
235
foreach
($links as $key => $link)
236
{
237
$adjustedLinks[$key] = $this->
adjustLink
($link);
238
}
239
240
$this->links = $adjustedLinks;
241
242
return
$this;
243
}
244
252
public
function
addLink
($name, $link)
253
{
254
$this->links[$name] = $this->
adjustLink
($link);
255
256
return
$this;
257
}
258
263
public
function
getAttributes
()
264
{
265
return
$this->attributes;
266
}
267
274
public
function
setAttributes
($attributes)
275
{
276
$this->attributes = $attributes;
277
278
return
$this;
279
}
280
288
public
function
setAttribute
($name, $value)
289
{
290
$this->attributes[$name] = $value;
291
292
return
$this;
293
}
294
301
public
function
unsetAttribute
($name)
302
{
303
unset($this->attributes[$name]);
304
305
return
$this;
306
}
307
315
public
function
jsonSerialize
(): array
316
{
317
return
[
318
'id'
=> $this->
getId
(),
319
'type'
=> $this->
getType
(),
320
'title'
=> $this->
getTitle
(),
321
'module'
=> $this->
getModule
(),
322
'subTitle'
=> $this->
getSubTitle
(),
323
'actions'
=> $this->
getActions
(),
324
'links'
=> $this->
getLinks
(),
325
'attributes'
=> $this->
getAttributes
(),
326
];
327
}
328
343
public
function
offsetExists
($offset): bool
344
{
345
$data = $this->
jsonSerialize
();
346
347
return
isset($data[$offset]) || array_key_exists($offset, $data);
348
}
349
361
#[\ReturnTypeWillChange]
362
public
function
offsetGet
($offset)
363
{
364
$data = $this->
jsonSerialize
();
365
366
if
(isset($data[$offset]) || array_key_exists($offset, $data))
367
{
368
return
$data[$offset];
369
}
370
371
return
null
;
372
}
373
388
public
function
offsetSet
($offset, $value): void
389
{
390
throw
new
NotSupportedException
(
'ResultItem provides ArrayAccess only for reading'
);
391
}
392
404
public
function
offsetUnset
($offset): void
405
{
406
throw
new
NotSupportedException
(
'ResultItem provides ArrayAccess only for reading'
);
407
}
408
}
Bitrix\Main\NotSupportedException
Definition
exception.php:159
Bitrix\Main\Search\ResultItem
Definition
resultitem.php:9
Bitrix\Main\Search\ResultItem\__construct
__construct($title, $showLink, $id=null)
Definition
resultitem.php:36
Bitrix\Main\Search\ResultItem\getLinks
getLinks()
Definition
resultitem.php:220
Bitrix\Main\Search\ResultItem\getId
getId()
Definition
resultitem.php:50
Bitrix\Main\Search\ResultItem\addLink
addLink($name, $link)
Definition
resultitem.php:252
Bitrix\Main\Search\ResultItem\setModule
setModule($module)
Definition
resultitem.php:173
Bitrix\Main\Search\ResultItem\offsetUnset
offsetUnset($offset)
Definition
resultitem.php:404
Bitrix\Main\Search\ResultItem\offsetExists
offsetExists($offset)
Definition
resultitem.php:343
Bitrix\Main\Search\ResultItem\getShowLink
getShowLink()
Definition
resultitem.php:121
Bitrix\Main\Search\ResultItem\setShowLink
setShowLink($showLink)
Definition
resultitem.php:132
Bitrix\Main\Search\ResultItem\getModule
getModule()
Definition
resultitem.php:161
Bitrix\Main\Search\ResultItem\setAttribute
setAttribute($name, $value)
Definition
resultitem.php:288
Bitrix\Main\Search\ResultItem\offsetGet
offsetGet($offset)
Definition
resultitem.php:362
Bitrix\Main\Search\ResultItem\setSubTitle
setSubTitle($subTitle)
Definition
resultitem.php:198
Bitrix\Main\Search\ResultItem\getType
getType()
Definition
resultitem.php:74
Bitrix\Main\Search\ResultItem\getSubTitle
getSubTitle()
Definition
resultitem.php:186
Bitrix\Main\Search\ResultItem\setId
setId($id)
Definition
resultitem.php:61
Bitrix\Main\Search\ResultItem\setTitle
setTitle($title)
Definition
resultitem.php:109
Bitrix\Main\Search\ResultItem\getTitle
getTitle()
Definition
resultitem.php:98
Bitrix\Main\Search\ResultItem\adjustLink
adjustLink($link)
Definition
resultitem.php:146
Bitrix\Main\Search\ResultItem\setAttributes
setAttributes($attributes)
Definition
resultitem.php:274
Bitrix\Main\Search\ResultItem\offsetSet
offsetSet($offset, $value)
Definition
resultitem.php:388
Bitrix\Main\Search\ResultItem\jsonSerialize
jsonSerialize()
Definition
resultitem.php:315
Bitrix\Main\Search\ResultItem\unsetAttribute
unsetAttribute($name)
Definition
resultitem.php:301
Bitrix\Main\Search\ResultItem\setLinks
setLinks(array $links)
Definition
resultitem.php:232
Bitrix\Main\Search\ResultItem\setType
setType($type)
Definition
resultitem.php:86
Bitrix\Main\Search\ResultItem\getActions
getActions()
Definition
resultitem.php:210
Bitrix\Main\Search\ResultItem\getAttributes
getAttributes()
Definition
resultitem.php:263
Bitrix\Main\Web\Uri
Definition
uri.php:17
Bitrix\Main\Search
Definition
content.php:3
modules
main
lib
search
resultitem.php
Создано системой
1.10.0