ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult Class Reference

@phpstan-type AutoCompleteUserItem array{label: string, value: string} @phpstan-type AutoCompleteResult array{items: list<AutoCompleteUserItem>, hasMoreResults: bool} More...

+ Inheritance diagram for ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult:
+ Collaboration diagram for ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult:

Public Member Functions

 __construct (int $mode)
 
 markMoreResultsAvailable ()
 
 addResult (string $identifier, string $firstname, string $lastname)
 
 getItems ()
 
 addResult (string $identifier, string $firstname, string $lastname)
 
 markMoreResultsAvailable ()
 

Data Fields

final const int MODE_STOP_ON_MAX_ENTRIES = 1
 
final const int MODE_FETCH_ALL = 2
 
final const int MAX_RESULT_ENTRIES = 1000
 
array $result
 

Private Member Functions

 initMode (int $mode)
 
 isResultAddable ()
 

Private Attributes

array $handled_recipients = []
 
int $mode = self::MODE_STOP_ON_MAX_ENTRIES
 
int $max_entries
 

Detailed Description

@phpstan-type AutoCompleteUserItem array{label: string, value: string} @phpstan-type AutoCompleteResult array{items: list<AutoCompleteUserItem>, hasMoreResults: bool}

Definition at line 29 of file LegacyAutocompleteSearchResult.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::__construct ( int  $mode)

Member Function Documentation

◆ addResult()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::addResult ( string  $identifier,
string  $firstname,
string  $lastname 
)

Implements ILIAS\Mail\RecipientSearch\SearchResult.

Definition at line 83 of file LegacyAutocompleteSearchResult.php.

84 {
85 if (!$this->isResultAddable()) {
86 throw new \DomainException('Search result is not addable!');
87 }
88
89 if ($identifier === '') {
90 return SearchResultStatus::IGNORED;
91 }
92
93 if (!isset($this->handled_recipients[$identifier])) {
94 $recipient = [];
95 $recipient['value'] = $identifier;
96
97 $label = $identifier;
98 if ($firstname && $lastname) {
99 $label .= ' [' . $firstname . ', ' . $lastname . ']';
100 }
101 $recipient['label'] = $label;
102
103 $this->result['items'][] = $recipient;
104 $this->handled_recipients[$identifier] = true;
105
106 if (!$this->isResultAddable()) {
108 }
109 }
110
111 return SearchResultStatus::DUPLICATE;
112 }

References ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult\isResultAddable(), and ILIAS\Mail\RecipientSearch\LIMIT_REACHED.

+ Here is the call graph for this function:

◆ getItems()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::getItems ( )

◆ initMode()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::initMode ( int  $mode)
private
Exceptions

InvalidArgumentException

Definition at line 55 of file LegacyAutocompleteSearchResult.php.

55 : void
56 {
57 if (!\in_array($mode, [self::MODE_FETCH_ALL, self::MODE_STOP_ON_MAX_ENTRIES], true)) {
58 throw new \InvalidArgumentException('Wrong mode passed!');
59 }
60 $this->mode = $mode;
61 }

References ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult\$mode.

Referenced by ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult\__construct().

+ Here is the caller graph for this function:

◆ isResultAddable()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::isResultAddable ( )
private

Definition at line 63 of file LegacyAutocompleteSearchResult.php.

63 : bool
64 {
65 if ($this->mode === self::MODE_STOP_ON_MAX_ENTRIES &&
66 $this->max_entries >= 0 && \count($this->result['items']) >= $this->max_entries) {
67 return false;
68 }
69
70 if ($this->mode === self::MODE_FETCH_ALL &&
71 \count($this->result['items']) >= self::MAX_RESULT_ENTRIES) {
72 return false;
73 }
74
75 return true;
76 }

Referenced by ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult\addResult().

+ Here is the caller graph for this function:

◆ markMoreResultsAvailable()

ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::markMoreResultsAvailable ( )

Implements ILIAS\Mail\RecipientSearch\SearchResult.

Definition at line 78 of file LegacyAutocompleteSearchResult.php.

78 : void
79 {
80 $this->result['hasMoreResults'] = true;
81 }

Field Documentation

◆ $handled_recipients

array ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::$handled_recipients = []
private

Definition at line 36 of file LegacyAutocompleteSearchResult.php.

◆ $max_entries

int ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::$max_entries
private

Definition at line 38 of file LegacyAutocompleteSearchResult.php.

◆ $mode

int ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::$mode = self::MODE_STOP_ON_MAX_ENTRIES
private

◆ $result

array ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::$result
Initial value:
= [
'items' => [],
'hasMoreResults' => false
]

Definition at line 40 of file LegacyAutocompleteSearchResult.php.

Referenced by ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult\getItems().

◆ MAX_RESULT_ENTRIES

final const int ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::MAX_RESULT_ENTRIES = 1000

Definition at line 33 of file LegacyAutocompleteSearchResult.php.

◆ MODE_FETCH_ALL

final const int ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::MODE_FETCH_ALL = 2

Definition at line 32 of file LegacyAutocompleteSearchResult.php.

◆ MODE_STOP_ON_MAX_ENTRIES

final const int ILIAS\Mail\RecipientSearch\LegacyAutocompleteSearchResult::MODE_STOP_ON_MAX_ENTRIES = 1

Definition at line 31 of file LegacyAutocompleteSearchResult.php.


The documentation for this class was generated from the following file: