ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
DefaultAutocompleteItem.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User\Search;
22
24{
25 public function __construct(
26 private readonly string $login,
27 private readonly string $lastname,
28 private readonly string $firstname,
29 private readonly string $unprocessed_search_term
30 ) {
31 }
32
33 public function getTagArray(): array
34 {
35 $return = [
36 'value' => rawurlencode($this->login),
37 'searchBy' => $this->unprocessed_search_term
38 ];
39
40 if ($this->lastname === '' && $this->firstname === '') {
41 return $return + [
42 'display' => $this->login
43 ];
44 }
45
46 return $return + [
47 'display' => "{$this->login} [{$this->buildNameComponent()}]"
48 ];
49 }
50
51 private function buildNameComponent(): string
52 {
53 if ($this->lastname !== '') {
54 return "{$this->lastname}, {$this->firstname}";
55 }
56
57 return $this->firstname;
58 }
59}
getTagArray()
MUST return an array containing three properties "value", "display", and "searchBy".
__construct(private readonly string $login, private readonly string $lastname, private readonly string $firstname, private readonly string $unprocessed_search_term)