19declare(strict_types=1);
31 private ?
int $period =
null,
32 private bool $only_public =
false,
33 private ?
int $min_priority =
null,
34 private ?
int $max_priority =
null,
35 private ?
int $limit =
null,
36 private bool $prevent_nesting =
false,
37 private bool $no_auto_generated =
false,
38 private array $excluded_news_ids = [],
39 private ?
bool $include_read_status =
null,
40 private ?
int $read_user_id =
null,
42 private array $start_dates = [],
45 $this->include_read_status = $this->include_read_status ?? !$this->only_public;
59 return $this->only_public;
64 return $this->min_priority;
69 return $this->max_priority;
79 return $this->prevent_nesting;
84 return $this->no_auto_generated;
89 return $this->excluded_news_ids;
94 return $this->include_read_status ??
false;
99 return $this->read_user_id;
107 return $this->start_dates;
113 $new->period = $period;
120 $new->only_public = $only_public;
127 $new->min_priority = $min_priority;
134 $new->max_priority = $max_priority;
141 $new->limit = $limit;
148 $new->prevent_nesting = $stop_nesting;
155 $new->no_auto_generated = $no_auto_generated;
162 $new->excluded_news_ids = array_map(
'intval', $excluded_news_ids);
169 $new->include_read_status = $include_read_status;
176 $new->read_user_id = $read_user_id;
186 $new->start_dates = $start_dates;
202 'period' => $this->period,
203 'only_public' => $this->only_public,
204 'min_priority' => $this->min_priority,
205 'max_priority' => $this->max_priority,
206 'limit' => $this->limit,
207 'stop_nesting' => $this->prevent_nesting,
208 'no_auto_generated' => $this->no_auto_generated,
209 'excluded_news_ids' => $this->excluded_news_ids,
210 'include_read_status' => $this->include_read_status,
211 'read_user_id' => $this->read_user_id,
212 'start_dates' => $this->start_dates
221 return $this->min_priority !==
null || $this->max_priority !==
null;
229 if ($this->min_priority !==
null && $this->max_priority !==
null && $this->min_priority > $this->max_priority) {
230 throw new \InvalidArgumentException(
'Min priority cannot be greater than max priority');
233 if ($this->limit !==
null && $this->limit < 0) {
234 throw new \InvalidArgumentException(
'Limit cannot be negative');
News Criteria DTO for querying news items supports caching, JSON serialization, and validation.
withMaxPriority(?int $max_priority)
withPreventNesting(bool $stop_nesting)
validate()
Validate criteria parameters.
withExcludedNewsIds(array $excluded_news_ids)
withNoAutoGenerated(bool $no_auto_generated)
withIncludeReadStatus(bool $include_read_status)
hasPriorityFilters()
Check if criteria has priority filters.
withMinPriority(?int $min_priority)
withReadUserId(?int $read_user_id)
withOnlyPublic(bool $only_public)
withStartDates(array $start_dates)
__construct()
Constructor setup ILIAS global object @access public.