‪TYPO3CMS  ‪main
ResultItemAction.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 ‪ResultItemAction implements \JsonSerializable
28 {
29  private string ‪$label = '';
30  private ?‪Icon ‪$icon = null;
31  private string ‪$url = '';
32 
36  public function ‪__construct(private readonly string ‪$identifier) {}
37 
38  public function ‪setLabel(string ‪$label): self
39  {
40  $this->label = ‪$label;
41 
42  return $this;
43  }
44 
45  public function ‪setIcon(?‪Icon ‪$icon): self
46  {
47  $this->icon = ‪$icon;
48 
49  return $this;
50  }
51 
52  public function ‪setUrl(string ‪$url): self
53  {
54  $this->url = ‪$url;
55 
56  return $this;
57  }
58 
59  public function ‪jsonSerialize(): array
60  {
61  return [
62  'identifier' => ‪$this->identifier,
63  'label' => ‪$this->label,
64  'icon' => [
65  'identifier' => $this->icon?->getIdentifier(),
66  'overlay' => $this->icon?->getOverlayIcon()?->getIdentifier(),
67  ],
68  'url' => ‪$this->url,
69  ];
70  }
71 }
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:27
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\setUrl
‪setUrl(string $url)
Definition: ResultItemAction.php:52
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\setLabel
‪setLabel(string $label)
Definition: ResultItemAction.php:38
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\setIcon
‪setIcon(?Icon $icon)
Definition: ResultItemAction.php:45
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\$icon
‪Icon $icon
Definition: ResultItemAction.php:30
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\jsonSerialize
‪jsonSerialize()
Definition: ResultItemAction.php:59
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\$url
‪string $url
Definition: ResultItemAction.php:31
‪TYPO3\CMS\Backend\Search\LiveSearch
Definition: DatabaseRecordProvider.php:18
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\$label
‪string $label
Definition: ResultItemAction.php:29
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction\__construct
‪__construct(private readonly string $identifier)
Definition: ResultItemAction.php:36
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Backend\Search\LiveSearch\ResultItemAction
Definition: ResultItemAction.php:28