ILIAS  trunk Revision v12.0_alpha-413-g215742c0453
SubtreeAggregationStrategy.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
29{
30 public function __construct(protected readonly \ilTree $tree)
31 {
32 }
33
37 public function aggregate(NewsContext $base_context): array
38 {
39 $aggregated = [];
40
41 foreach ($this->tree->getChilds($base_context->getRefId()) as $node) {
42 $aggregated[] = new NewsContext(
43 $node['child'],
44 $node['obj_id'],
45 $node['type'],
46 $base_context->getRefId(),
47 $base_context->getLevel() + 1
48 );
49 }
50
51 return $aggregated;
52 }
53
54 public function isRecursive(): bool
55 {
56 return false;
57 }
58
59 public function shouldSkip(NewsContext $context): bool
60 {
61 // see #31471, #30687, and ilMembershipNotification
62 return !\ilContainer::_lookupContainerSetting($context->getObjId(), 'cont_use_news', '1')
63 || (!\ilContainer::_lookupContainerSetting($context->getObjId(), 'cont_show_news', '1')
64 && !\ilContainer::_lookupContainerSetting($context->getObjId(), 'news_timeline'));
65 }
66}
Subtree Aggregation Strategy aggregates related contexts for groups and courses.
isRecursive()
Returns true if the strategy already resolves contexts recursively (which is more performant in some ...
shouldSkip(NewsContext $context)
Returns true if the provided context should not be aggregated.
News Context DTO represents a context where news items can be associated with.
Definition: NewsContext.php:29
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
News Aggregation Strategy Interface defines the contract for news aggregation strategies.
$context
Definition: webdav.php:31