ILIAS  trunk Revision v12.0_alpha-399-g579a087ced2
ILIAS\News\Data\NewsCriteria Class Reference

News Criteria DTO for querying news items supports caching, JSON serialization, and validation. More...

+ Inheritance diagram for ILIAS\News\Data\NewsCriteria:
+ Collaboration diagram for ILIAS\News\Data\NewsCriteria:

Public Member Functions

 __construct (private ?DateTimeImmutable $start_date=null, private ?int $period=null, private bool $only_public=false, private ?int $min_priority=null, private ?int $max_priority=null, private ?int $limit=null, private bool $prevent_nesting=false, private bool $no_auto_generated=false, private array $excluded_news_ids=[], private ?bool $include_read_status=null, private ?int $read_user_id=null,)
 
 getStartDate ()
 
 getPeriod ()
 
 isOnlyPublic ()
 
 getMinPriority ()
 
 getMaxPriority ()
 
 getLimit ()
 
 isPreventNesting ()
 
 isNoAutoGenerated ()
 
 getExcludedNewsIds ()
 
 isIncludeReadStatus ()
 
 getReadUserId ()
 
 withStartDate (?DateTimeImmutable $start_date)
 
 withPeriod (?int $period)
 
 withOnlyPublic (bool $only_public)
 
 withMinPriority (?int $min_priority)
 
 withMaxPriority (?int $max_priority)
 
 withLimit (?int $limit)
 
 withPreventNesting (bool $stop_nesting)
 
 withNoAutoGenerated (bool $no_auto_generated)
 
 withExcludedNewsIds (array $excluded_news_ids)
 
 withIncludeReadStatus (bool $include_read_status)
 
 withReadUserId (?int $read_user_id)
 
 jsonSerialize ()
 
 toArray ()
 
 hasPriorityFilters ()
 Check if criteria has priority filters. More...
 
 validate ()
 Validate criteria parameters. More...
 

Detailed Description

News Criteria DTO for querying news items supports caching, JSON serialization, and validation.

Definition at line 28 of file NewsCriteria.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\News\Data\NewsCriteria::__construct ( private ?DateTimeImmutable  $start_date = null,
private ?int  $period = null,
private bool  $only_public = false,
private ?int  $min_priority = null,
private ?int  $max_priority = null,
private ?int  $limit = null,
private bool  $prevent_nesting = false,
private bool  $no_auto_generated = false,
private array  $excluded_news_ids = [],
private ?bool  $include_read_status = null,
private ?int  $read_user_id = null 
)

Definition at line 30 of file NewsCriteria.php.

42 {
43 // By default, include read status if only public is not set
44 $this->include_read_status = $this->include_read_status ?? !$this->only_public;
45 }

Member Function Documentation

◆ getExcludedNewsIds()

ILIAS\News\Data\NewsCriteria::getExcludedNewsIds ( )

Definition at line 91 of file NewsCriteria.php.

91 : array
92 {
93 return $this->excluded_news_ids;
94 }

Referenced by ILIAS\News\Domain\NewsCollectionService\applyFinalProcessing().

+ Here is the caller graph for this function:

◆ getLimit()

ILIAS\News\Data\NewsCriteria::getLimit ( )

Definition at line 76 of file NewsCriteria.php.

76 : ?int
77 {
78 return $this->limit;
79 }

Referenced by ILIAS\News\Domain\NewsCollectionService\applyFinalProcessing().

+ Here is the caller graph for this function:

◆ getMaxPriority()

ILIAS\News\Data\NewsCriteria::getMaxPriority ( )

Definition at line 71 of file NewsCriteria.php.

71 : ?int
72 {
73 return $this->max_priority;
74 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), and ILIAS\News\Persistence\NewsCache\generateL3Key().

+ Here is the caller graph for this function:

◆ getMinPriority()

ILIAS\News\Data\NewsCriteria::getMinPriority ( )

Definition at line 66 of file NewsCriteria.php.

66 : ?int
67 {
68 return $this->min_priority;
69 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), and ILIAS\News\Persistence\NewsCache\generateL3Key().

+ Here is the caller graph for this function:

◆ getPeriod()

ILIAS\News\Data\NewsCriteria::getPeriod ( )

Definition at line 56 of file NewsCriteria.php.

56 : ?int
57 {
58 return $this->period;
59 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), and ILIAS\News\Persistence\NewsCache\generateL3Key().

+ Here is the caller graph for this function:

◆ getReadUserId()

ILIAS\News\Data\NewsCriteria::getReadUserId ( )

◆ getStartDate()

ILIAS\News\Data\NewsCriteria::getStartDate ( )

Definition at line 51 of file NewsCriteria.php.

51 : ?DateTimeImmutable
52 {
53 return $this->start_date;
54 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), and ILIAS\News\Persistence\NewsCache\generateL3Key().

+ Here is the caller graph for this function:

◆ hasPriorityFilters()

ILIAS\News\Data\NewsCriteria::hasPriorityFilters ( )

Check if criteria has priority filters.

Definition at line 212 of file NewsCriteria.php.

212 : bool
213 {
214 return $this->min_priority !== null || $this->max_priority !== null;
215 }

◆ isIncludeReadStatus()

ILIAS\News\Data\NewsCriteria::isIncludeReadStatus ( )

Definition at line 96 of file NewsCriteria.php.

96 : bool
97 {
98 return $this->include_read_status ?? false;
99 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), ILIAS\News\Persistence\NewsRepository\findByContextsBatch(), ILIAS\News\Persistence\NewsRepository\findByContextsBatchLazy(), and ILIAS\News\Domain\NewsCollectionService\getNewsForUser().

+ Here is the caller graph for this function:

◆ isNoAutoGenerated()

ILIAS\News\Data\NewsCriteria::isNoAutoGenerated ( )

Definition at line 86 of file NewsCriteria.php.

86 : bool
87 {
88 return $this->no_auto_generated;
89 }

Referenced by ILIAS\News\Persistence\NewsRepository\buildBatchQuery(), and ILIAS\News\Persistence\NewsCache\generateL3Key().

+ Here is the caller graph for this function:

◆ isOnlyPublic()

ILIAS\News\Data\NewsCriteria::isOnlyPublic ( )

◆ isPreventNesting()

ILIAS\News\Data\NewsCriteria::isPreventNesting ( )

Definition at line 81 of file NewsCriteria.php.

81 : bool
82 {
83 return $this->prevent_nesting;
84 }

Referenced by ILIAS\News\Domain\NewsCollectionService\getNewsForContexts().

+ Here is the caller graph for this function:

◆ jsonSerialize()

ILIAS\News\Data\NewsCriteria::jsonSerialize ( )

Definition at line 187 of file NewsCriteria.php.

187 : array
188 {
189 return $this->toArray();
190 }

References ILIAS\News\Data\NewsCriteria\toArray().

+ Here is the call graph for this function:

◆ toArray()

ILIAS\News\Data\NewsCriteria::toArray ( )

Definition at line 192 of file NewsCriteria.php.

192 : array
193 {
194 return [
195 'start_date' => $this->start_date?->format('Y-m-d H:i:s'),
196 'period' => $this->period,
197 'only_public' => $this->only_public,
198 'min_priority' => $this->min_priority,
199 'max_priority' => $this->max_priority,
200 'limit' => $this->limit,
201 'stop_nesting' => $this->prevent_nesting,
202 'no_auto_generated' => $this->no_auto_generated,
203 'excluded_news_ids' => $this->excluded_news_ids,
204 'include_read_status' => $this->include_read_status,
205 'read_user_id' => $this->read_user_id,
206 ];
207 }

Referenced by ILIAS\News\Data\NewsCriteria\jsonSerialize().

+ Here is the caller graph for this function:

◆ validate()

ILIAS\News\Data\NewsCriteria::validate ( )

Validate criteria parameters.

Definition at line 220 of file NewsCriteria.php.

220 : void
221 {
222 if ($this->min_priority !== null && $this->max_priority !== null && $this->min_priority > $this->max_priority) {
223 throw new \InvalidArgumentException('Min priority cannot be greater than max priority');
224 }
225
226 if ($this->limit !== null && $this->limit < 0) {
227 throw new \InvalidArgumentException('Limit cannot be negative');
228 }
229 }

Referenced by ILIAS\News\Domain\NewsCollectionService\getNewsForUser().

+ Here is the caller graph for this function:

◆ withExcludedNewsIds()

ILIAS\News\Data\NewsCriteria::withExcludedNewsIds ( array  $excluded_news_ids)

Definition at line 162 of file NewsCriteria.php.

162 : self
163 {
164 $new = clone $this;
165 $new->excluded_news_ids = array_map('intval', $excluded_news_ids);
166 return $new;
167 }

◆ withIncludeReadStatus()

ILIAS\News\Data\NewsCriteria::withIncludeReadStatus ( bool  $include_read_status)

Definition at line 169 of file NewsCriteria.php.

169 : self
170 {
171 $new = clone $this;
172 $new->include_read_status = $include_read_status;
173 return $new;
174 }

◆ withLimit()

ILIAS\News\Data\NewsCriteria::withLimit ( ?int  $limit)

Definition at line 141 of file NewsCriteria.php.

141 : self
142 {
143 $new = clone $this;
144 $new->limit = $limit;
145 return $new;
146 }

◆ withMaxPriority()

ILIAS\News\Data\NewsCriteria::withMaxPriority ( ?int  $max_priority)

Definition at line 134 of file NewsCriteria.php.

134 : self
135 {
136 $new = clone $this;
137 $new->max_priority = $max_priority;
138 return $new;
139 }

◆ withMinPriority()

ILIAS\News\Data\NewsCriteria::withMinPriority ( ?int  $min_priority)

Definition at line 127 of file NewsCriteria.php.

127 : self
128 {
129 $new = clone $this;
130 $new->min_priority = $min_priority;
131 return $new;
132 }

◆ withNoAutoGenerated()

ILIAS\News\Data\NewsCriteria::withNoAutoGenerated ( bool  $no_auto_generated)

Definition at line 155 of file NewsCriteria.php.

155 : self
156 {
157 $new = clone $this;
158 $new->no_auto_generated = $no_auto_generated;
159 return $new;
160 }

◆ withOnlyPublic()

ILIAS\News\Data\NewsCriteria::withOnlyPublic ( bool  $only_public)

Definition at line 120 of file NewsCriteria.php.

120 : self
121 {
122 $new = clone $this;
123 $new->only_public = $only_public;
124 return $new;
125 }

◆ withPeriod()

ILIAS\News\Data\NewsCriteria::withPeriod ( ?int  $period)

Definition at line 113 of file NewsCriteria.php.

113 : self
114 {
115 $new = clone $this;
116 $new->period = $period;
117 return $new;
118 }

◆ withPreventNesting()

ILIAS\News\Data\NewsCriteria::withPreventNesting ( bool  $stop_nesting)

Definition at line 148 of file NewsCriteria.php.

148 : self
149 {
150 $new = clone $this;
151 $new->prevent_nesting = $stop_nesting;
152 return $new;
153 }

◆ withReadUserId()

ILIAS\News\Data\NewsCriteria::withReadUserId ( ?int  $read_user_id)

Definition at line 176 of file NewsCriteria.php.

176 : self
177 {
178 $new = clone $this;
179 $new->read_user_id = $read_user_id;
180 return $new;
181 }

Referenced by ILIAS\News\Domain\NewsCollectionService\getNewsForUser().

+ Here is the caller graph for this function:

◆ withStartDate()

ILIAS\News\Data\NewsCriteria::withStartDate ( ?DateTimeImmutable  $start_date)

Definition at line 106 of file NewsCriteria.php.

106 : self
107 {
108 $new = clone $this;
109 $new->start_date = $start_date;
110 return $new;
111 }

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