ILIAS  trunk Revision v12.0_alpha-413-g215742c0453
ILIAS\News\Data\NewsContext Class Reference

News Context DTO represents a context where news items can be associated with. More...

+ Collaboration diagram for ILIAS\News\Data\NewsContext:

Public Member Functions

 __construct (private readonly int $ref_id, private ?int $obj_id=null, private ?string $obj_type=null, private ?int $parent_ref_id=null, private int $level=0,)
 
 getRefId ()
 
 getObjId ()
 
 getObjType ()
 
 getParentRefId ()
 
 setObjId (int $obj_id)
 
 setObjType (string $obj_type)
 
 setParentRefId (?int $parent_ref_id)
 
 setLevel (int $level)
 
 getLevel ()
 
 isChildOf (NewsContext $parent_context)
 Check if this context is a child of another context. More...
 
 isParentOf (NewsContext $child_context)
 Check if this context is a parent of another context. More...
 
 isRoot ()
 Check if this context is at the root level. More...
 
 normalize ()
 Transform this object into array representation and keep only properties which are not default values. More...
 

Static Public Member Functions

static denormalize (array $raw)
 Create new object from reduced array representation. More...
 

Detailed Description

News Context DTO represents a context where news items can be associated with.

It encapsulates all relevant information about the context and provides validation, caching, and serialization capabilities.

Definition at line 28 of file NewsContext.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\News\Data\NewsContext::__construct ( private readonly int  $ref_id,
private ?int  $obj_id = null,
private ?string  $obj_type = null,
private ?int  $parent_ref_id = null,
private int  $level = 0 
)

Definition at line 30 of file NewsContext.php.

36 {
37 }

Member Function Documentation

◆ denormalize()

static ILIAS\News\Data\NewsContext::denormalize ( array  $raw)
static

Create new object from reduced array representation.

Parameters
array<string,mixed>$raw
Returns
self

Definition at line 145 of file NewsContext.php.

145 : self
146 {
147 return new self(
148 $raw['ref_id'],
149 $raw['obj_id'] ?? null,
150 $raw['obj_type'] ?? null,
151 $raw['parent_ref_id'] ?? null,
152 $raw['level'] ?? 0,
153 );
154 }

Referenced by ILIAS\News\Persistence\NewsCache\getAggregatedContexts().

+ Here is the caller graph for this function:

◆ getLevel()

ILIAS\News\Data\NewsContext::getLevel ( )
Returns
int The level of this context in the hierarchy of contexts. This is different from the depth in the ilias tree because it will be considered relative.

Definition at line 91 of file NewsContext.php.

91 : int
92 {
93 return $this->level;
94 }

Referenced by ILIAS\News\Aggregation\SubtreeAggregationStrategy\aggregate().

+ Here is the caller graph for this function:

◆ getObjId()

ILIAS\News\Data\NewsContext::getObjId ( )

Definition at line 48 of file NewsContext.php.

48 : ?int
49 {
50 return $this->obj_id;
51 }

◆ getObjType()

ILIAS\News\Data\NewsContext::getObjType ( )

Definition at line 53 of file NewsContext.php.

53 : ?string
54 {
55 return $this->obj_type;
56 }

◆ getParentRefId()

ILIAS\News\Data\NewsContext::getParentRefId ( )

Definition at line 58 of file NewsContext.php.

58 : ?int
59 {
60 return $this->parent_ref_id;
61 }

Referenced by ILIAS\News\Data\NewsContext\isParentOf().

+ Here is the caller graph for this function:

◆ getRefId()

ILIAS\News\Data\NewsContext::getRefId ( )

Definition at line 43 of file NewsContext.php.

43 : int
44 {
45 return $this->ref_id;
46 }
$ref_id
Definition: ltiauth.php:66

References $ref_id.

Referenced by ILIAS\News\Aggregation\SubtreeAggregationStrategy\aggregate(), and ILIAS\News\Data\NewsContext\isChildOf().

+ Here is the caller graph for this function:

◆ isChildOf()

ILIAS\News\Data\NewsContext::isChildOf ( NewsContext  $parent_context)

Check if this context is a child of another context.

Definition at line 103 of file NewsContext.php.

103 : bool
104 {
105 return $this->parent_ref_id === $parent_context->getRefId();
106 }

References ILIAS\News\Data\NewsContext\getRefId().

+ Here is the call graph for this function:

◆ isParentOf()

ILIAS\News\Data\NewsContext::isParentOf ( NewsContext  $child_context)

Check if this context is a parent of another context.

Definition at line 111 of file NewsContext.php.

111 : bool
112 {
113 return $child_context->getParentRefId() === $this->ref_id;
114 }

References $ref_id, and ILIAS\News\Data\NewsContext\getParentRefId().

+ Here is the call graph for this function:

◆ isRoot()

ILIAS\News\Data\NewsContext::isRoot ( )

Check if this context is at the root level.

Definition at line 119 of file NewsContext.php.

119 : bool
120 {
121 return $this->parent_ref_id === null;
122 }

◆ normalize()

ILIAS\News\Data\NewsContext::normalize ( )

Transform this object into array representation and keep only properties which are not default values.

Returns
array<string, mixed>

Definition at line 133 of file NewsContext.php.

133 : array
134 {
135 $vars = get_object_vars($this);
136 return array_filter($vars);
137 }

◆ setLevel()

ILIAS\News\Data\NewsContext::setLevel ( int  $level)

Definition at line 81 of file NewsContext.php.

81 : self
82 {
83 $this->level = $level;
84 return $this;
85 }

◆ setObjId()

ILIAS\News\Data\NewsContext::setObjId ( int  $obj_id)

Definition at line 63 of file NewsContext.php.

63 : self
64 {
65 $this->obj_id = $obj_id;
66 return $this;
67 }

◆ setObjType()

ILIAS\News\Data\NewsContext::setObjType ( string  $obj_type)

Definition at line 69 of file NewsContext.php.

69 : self
70 {
71 $this->obj_type = $obj_type;
72 return $this;
73 }

◆ setParentRefId()

ILIAS\News\Data\NewsContext::setParentRefId ( ?int  $parent_ref_id)

Definition at line 75 of file NewsContext.php.

75 : self
76 {
77 $this->parent_ref_id = $parent_ref_id;
78 return $this;
79 }

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