ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
BlockDTO.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilDateTime;
24
26{
27 public function __construct(
28 private string $type,
29 private int $ref_id,
30 private int $obj_id,
31 private string $title,
32 private string $description,
33 private ?ilDateTime $startDate = null,
34 private ?ilDateTime $endDate = null,
35 private array $additional_data = []
36 ) {
37 $this->type = $type;
38 $this->ref_id = $ref_id;
39 $this->obj_id = $obj_id;
40 $this->title = $title;
41 $this->description = $description;
42 $this->startDate = $startDate;
43 $this->endDate = $endDate;
44 $this->additional_data = $additional_data;
45 }
46
47 public function getType(): string
48 {
49 return $this->type;
50 }
51
52 public function setType(string $type): void
53 {
54 $this->type = $type;
55 }
56
57 public function getRefId(): int
58 {
59 return $this->ref_id;
60 }
61
62 public function setRefId(int $ref_id): void
63 {
64 $this->ref_id = $ref_id;
65 }
66
67 public function getObjId(): int
68 {
69 return $this->obj_id;
70 }
71
72 public function setObjId(int $obj_id): void
73 {
74 $this->obj_id = $obj_id;
75 }
76
77 public function getTitle(): string
78 {
79 return $this->title;
80 }
81
82 public function setTitle(string $title): void
83 {
84 $this->title = $title;
85 }
86
87 public function getDescription(): string
88 {
89 return $this->description;
90 }
91
92 public function setDescription(string $description): void
93 {
94 $this->description = $description;
95 }
96
97 public function getStartDate(): ?ilDateTime
98 {
99 return $this->startDate;
100 }
101
102 public function setStartDate(?ilDateTime $startDate): void
103 {
104 $this->startDate = $startDate;
105 }
106
107 public function getEndDate(): ?ilDateTime
108 {
109 return $this->endDate;
110 }
111
112 public function setEndDate(?ilDateTime $endDate): void
113 {
114 $this->endDate = $endDate;
115 }
116
117 public function hasNotStarted(): bool
118 {
119 return $this->startDate && $this->startDate->get(IL_CAL_UNIX) > time();
120 }
121
122 public function hasEnded(): bool
123 {
124 return $this->endDate && $this->endDate->get(IL_CAL_UNIX) < time();
125 }
126
127 public function isRunning(): bool
128 {
129 return !$this->hasNotStarted() && !$this->hasEnded();
130 }
131
132 public function isDated(): bool
133 {
134 return $this->startDate || $this->endDate;
135 }
136
137 public function getAdditionalData(): array
138 {
139 return $this->additional_data;
140 }
141
142 public function setAdditionalData(array $additional_data): void
143 {
144 $this->additional_data = $additional_data;
145 }
146
147 public function toArray(): array
148 {
149 return [
150 'type' => $this->type,
151 'ref_id' => $this->ref_id,
152 'obj_id' => $this->obj_id,
153 'title' => $this->title,
154 'description' => $this->description,
155 'start_date' => $this->startDate?->get(IL_CAL_DATETIME),
156 'end_date' => $this->endDate?->get(IL_CAL_DATETIME),
157 'additional_data' => $this->additional_data
158 ];
159 }
160}
__construct(private string $type, private int $ref_id, private int $obj_id, private string $title, private string $description, private ?ilDateTime $startDate=null, private ?ilDateTime $endDate=null, private array $additional_data=[])
Definition: BlockDTO.php:27
setStartDate(?ilDateTime $startDate)
Definition: BlockDTO.php:102
setAdditionalData(array $additional_data)
Definition: BlockDTO.php:142
const IL_CAL_UNIX
const IL_CAL_DATETIME
@classDescription Date and time handling
$ref_id
Definition: ltiauth.php:66