19declare(strict_types=1);
49 $cached_news = $this->cache->getNewsForUser($user->
getId(), $criteria);
50 if ($cached_news !==
null) {
55 $news_collection = $cached_news->withFetchCallback(
56 fn(...$args) => $this->
repository->loadLazyItems(...$args)
71 $user_contexts = $this->user_context_resolver->getAccessibleContexts($user, $criteria);
72 if (empty($user_contexts)) {
80 $this->cache->storeNewsForUser($user->
getId(), $criteria, $news_collection);
102 $cached = $this->cache->getAggregatedContexts($contexts);
103 $hits = $cached[
'hit'];
105 if (!empty($cached[
'missing'])) {
112 $this->cache->storeAggregatedContexts($remaining, $aggregated);
113 $hits = array_merge($hits, $aggregated);
115 $hits = array_merge($hits, $remaining);
124 ? $this->
repository->findByContextsBatchLazy($aggregated, $criteria)
125 : $this->
repository->findByContextsBatch($aggregated, $criteria);
135 $obj_ids = array_filter(array_map(fn(
$context) =>
$context->getObjId(), $contexts));
136 $this->object_data->preloadObjectCache($obj_ids);
138 for ($i = 0; $i < count($contexts); $i++) {
141 if (
$context->getObjId() ===
null) {
145 if (
$context->getObjType() ===
null) {
170 if ($this->
access->checkAccess(
'read',
'', $context->getRefId())) {
News Aggregator aggregates related contexts for a news context using a layer-wise Batching BFS to agg...
This class is a special implementation of a NewsCollection that is designed to load the complete News...
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.
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...
applyFinalProcessing(NewsCollection $collection, NewsCriteria $criteria)
Apply the last steps of the news collection processing pipeline: Exclude, Limit.
getNewsForContexts(array $contexts, NewsCriteria $criteria, bool $lazy)
fetchContextData(array $contexts)
filterByAccess(array $contexts, NewsCriteria $criteria)
getNewsForContext(NewsContext $context, NewsCriteria $criteria, bool $lazy=false)
getNewsForUser(\ilObjUser $user, NewsCriteria $criteria, bool $lazy=false)
invalidateCache(int $user_id)
__construct(private readonly NewsRepository $repository, private readonly NewsCache $cache, private readonly UserContextResolver $user_context_resolver, private readonly \ilObjectDataCache $object_data, private readonly \ilAccessHandler $access,)
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 preloadData(array $ref_ids)
Preload data to internal cache.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...