‪TYPO3CMS  ‪main
ResultItem.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 
27 final class ‪ResultItem implements \JsonSerializable
28 {
29  private string ‪$itemTitle = '';
30  private string ‪$typeLabel = '';
31  private ?‪Icon ‪$icon = null;
35  private array ‪$actions = [];
36  private array ‪$extraData = [];
37  private array ‪$internalData = [];
38 
42  public function ‪__construct(private readonly string $providerClassName) {}
43 
44  public function ‪getProviderClassName(): string
45  {
46  return $this->providerClassName;
47  }
48 
49  public function ‪setItemTitle(string ‪$itemTitle): self
50  {
51  $this->itemTitle = ‪$itemTitle;
52 
53  return $this;
54  }
55 
56  public function ‪setTypeLabel(string ‪$typeLabel): self
57  {
58  $this->typeLabel = ‪$typeLabel;
59 
60  return $this;
61  }
62 
63  public function ‪setIcon(‪Icon ‪$icon): self
64  {
65  $this->icon = ‪$icon;
66 
67  return $this;
68  }
69 
70  public function ‪setActions(‪ResultItemAction ...$action): self
71  {
72  $this->actions = $action;
73 
74  return $this;
75  }
76 
77  public function ‪addAction(‪ResultItemAction $action): self
78  {
79  $this->actions[] = $action;
80 
81  return $this;
82  }
83 
84  public function ‪getExtraData(): array
85  {
86  return ‪$this->extraData;
87  }
88 
90  {
91  $this->extraData = ‪$extraData;
92  return $this;
93  }
94 
95  public function ‪getInternalData(): array
96  {
98  }
99 
101  {
102  $this->internalData = ‪$internalData;
103 
104  return $this;
105  }
106 
107  public function ‪jsonSerialize(): array
108  {
109  return [
110  'provider' => $this->providerClassName,
111  'itemTitle' => ‪$this->itemTitle,
112  'typeLabel' => ‪$this->typeLabel,
113  'icon' => [
114  'identifier' => $this->icon?->getIdentifier(),
115  'overlay' => $this->icon?->getOverlayIcon()?->getIdentifier(),
116  ],
117  'actions' => ‪$this->actions,
118  'extraData' => ‪$this->extraData,
119  ];
120  }
121 }
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\jsonSerialize
‪jsonSerialize()
Definition: ResultItem.php:107
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setExtraData
‪setExtraData(array $extraData)
Definition: ResultItem.php:89
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$internalData
‪array $internalData
Definition: ResultItem.php:37
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setActions
‪setActions(ResultItemAction ... $action)
Definition: ResultItem.php:70
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:27
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$itemTitle
‪string $itemTitle
Definition: ResultItem.php:29
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$extraData
‪array $extraData
Definition: ResultItem.php:36
‪TYPO3\CMS\Backend\Search\LiveSearch
Definition: DatabaseRecordProvider.php:18
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\getExtraData
‪getExtraData()
Definition: ResultItem.php:84
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\getInternalData
‪getInternalData()
Definition: ResultItem.php:95
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\getProviderClassName
‪getProviderClassName()
Definition: ResultItem.php:44
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setItemTitle
‪setItemTitle(string $itemTitle)
Definition: ResultItem.php:49
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setIcon
‪setIcon(Icon $icon)
Definition: ResultItem.php:63
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$icon
‪Icon $icon
Definition: ResultItem.php:31
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$actions
‪array $actions
Definition: ResultItem.php:35
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setTypeLabel
‪setTypeLabel(string $typeLabel)
Definition: ResultItem.php:56
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem
Definition: ResultItem.php:28
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\addAction
‪addAction(ResultItemAction $action)
Definition: ResultItem.php:77
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\__construct
‪__construct(private readonly string $providerClassName)
Definition: ResultItem.php:42
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\setInternalData
‪setInternalData(array $internalData)
Definition: ResultItem.php:100
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction
Definition: ResultItemAction.php:28
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItem\$typeLabel
‪string $typeLabel
Definition: ResultItem.php:30