19declare(strict_types=1);
48 $cached_news = $this->cache->getNewsForUser($user->
getId(), $criteria);
49 if ($cached_news !==
null) {
54 $news_collection = $cached_news->withFetchCallback(
55 fn(...$args) => $this->
repository->loadLazyItems(...$args)
70 $user_contexts = $this->user_context_resolver->getAccessibleContexts($user, $criteria);
71 if (empty($user_contexts)) {
79 $this->cache->storeNewsForUser($user->
getId(), $criteria, $news_collection);
102 if (in_array($context_type, [
'grp',
'crs'])) {
114 if (!empty($hide_date)) {
115 $criteria = $criteria->
withStartDate(
new \DateTimeImmutable($hide_date));
121 return $this->applyFinalProcessing($this->getNewsForContexts([$context], $criteria,
$user_id, $lazy), $criteria);
135 $cached = $this->cache->getAggregatedContexts($contexts);
136 $hits = $cached[
'hit'];
138 if (!empty($cached[
'missing'])) {
140 $remaining = $this->fetchContextData($cached[
'missing']);
145 $this->cache->storeAggregatedContexts($remaining, $aggregated);
146 $hits = array_merge($hits, $aggregated);
148 $hits = array_merge($hits, $remaining);
153 $aggregated = $this->filterByAccess($hits, $criteria,
$user_id);
157 ? $this->
repository->findByContextsBatchLazy($aggregated, $criteria)
158 : $this->
repository->findByContextsBatch($aggregated, $criteria);
168 $obj_ids = array_filter(array_map(fn($context) => $context->getObjId(), $contexts));
169 $this->object_data->preloadObjectCache($obj_ids);
171 for ($i = 0; $i < count($contexts); $i++) {
172 $context = $contexts[$i];
174 if ($context->getObjId() ===
null) {
175 $context->setObjId($this->object_data->lookupObjId($context->getRefId()));
178 if ($context->getObjType() ===
null) {
179 $context->setObjType($this->object_data->lookupType($context->getObjId()));
182 $contexts[$i] = $context;
199 $contexts = $this->
repository->filterContext($contexts, $criteria);
202 $this->
rbac->preloadRbacPaCache(array_map(fn($context) => $context->getRefId(), $contexts),
$user_id);
205 usort($contexts, fn(
$a,
$b) =>
$a->getLevel() <=>
$b->getLevel());
209 foreach ($contexts as $context) {
211 if (isset($ac_result[$context->getParentRefId()]) && !$ac_result[$context->getParentRefId()]) {
215 $ac_result[$context->getRefId()] = $this->
rbac->checkAccess(
217 $context->getRefId(),
218 $context->getObjType(),
221 if ($ac_result[$context->getRefId()]) {
222 $filtered[] = $context;
News Aggregator aggregates related contexts for a news context using a layer-wise Batching BFS to agg...
Optimized News Collection with memory-efficient data structures to support large news feeds.
exclude(array $news_ids)
Returns a new collection with only the news items that are not in the provided list.
News Context DTO represents a context where news items can be associated with.
News Criteria DTO for querying news items supports caching, JSON serialization, and validation.
withStartDate(?DateTimeImmutable $start_date)
validate()
Validate criteria parameters.
withReadUserId(?int $read_user_id)
News Collection Service orchestrates all news-related operations and provides a high-level API for th...
__construct(private readonly NewsRepository $repository, private readonly NewsCache $cache, private readonly UserContextResolver $user_context_resolver, private readonly \ilObjectDataCache $object_data, private readonly \ilRbacSystem $rbac)
applyFinalProcessing(NewsCollection $collection, NewsCriteria $criteria)
Apply the last steps of the news collection processing pipeline: Exclude, Limit.
fetchContextData(array $contexts)
getNewsForContext(NewsContext $context, NewsCriteria $criteria, int $user_id, bool $lazy=false)
filterByAccess(array $contexts, NewsCriteria $criteria, int $user_id)
getNewsForUser(\ilObjUser $user, NewsCriteria $criteria, bool $lazy=false)
getNewsForContainer(int $ref_id, int $context_obj_id, string $context_type, NewsCriteria $criteria, int $user_id, bool $lazy=false)
invalidateCache(int $user_id)
getNewsForContexts(array $contexts, NewsCriteria $criteria, int $user_id, bool $lazy)
User Context Resolver resolves which contexts a user can access for news operations.
Multi-Level News Cache Implementation:
News Repository provides basic CRUD operations and optimized database access for news operations with...
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
if(!file_exists('../ilias.ini.php'))