ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBuddySystemRelation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
29
30 public function __construct(
32 protected int $usrId,
33 protected int $buddyUsrId,
34 protected bool $isOwnedByActor,
35 protected int $timestamp
36 ) {
37 $this->setState($state, false);
38 }
39
40 private function setPriorState(ilBuddySystemRelationState $prior_state): void
41 {
42 $this->priorState = $prior_state;
43 }
44
45 public function setState(ilBuddySystemRelationState $state, bool $rememberPriorState = true): self
46 {
47 if ($rememberPriorState) {
48 $this->setPriorState($this->getState());
49 }
50
51 $this->state = $state;
52 return $this;
53 }
54
56 {
57 return $this->state;
58 }
59
61 {
62 return $this->priorState;
63 }
64
65 public function isOwnedByActor(): bool
66 {
67 return $this->isOwnedByActor;
68 }
69
70 public function withIsOwnedByActor(bool $isOwnedByActor): self
71 {
72 $clone = clone $this;
73 $clone->isOwnedByActor = $isOwnedByActor;
74
75 return $clone;
76 }
77
78 public function getBuddyUsrId(): int
79 {
80 return $this->buddyUsrId;
81 }
82
83 public function withBuddyUsrId(int $buddyUsrId): self
84 {
85 $clone = clone $this;
86 $clone->buddyUsrId = $buddyUsrId;
87
88 return $clone;
89 }
90
91 public function getUsrId(): int
92 {
93 return $this->usrId;
94 }
95
96 public function withUsrId(int $usrId): self
97 {
98 $clone = clone $this;
99 $clone->usrId = $usrId;
100
101 return $clone;
102 }
103
104 public function getTimestamp(): int
105 {
106 return $this->timestamp;
107 }
108
109 public function withTimestamp(int $timestamp): self
110 {
111 $clone = clone $this;
112 $clone->timestamp = $timestamp;
113
114 return $clone;
115 }
116
118 {
119 return ilBuddySystemRelationStateFilterRuleFactory::getInstance()->getFilterRuleByRelation($this)->getStates();
120 }
121
125 public function link(): self
126 {
127 if ($this->getUsrId() === $this->getBuddyUsrId()) {
128 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
129 }
130
131 $this->getState()->link($this);
132 return $this;
133 }
134
138 public function unlink(): self
139 {
140 if ($this->getUsrId() === $this->getBuddyUsrId()) {
141 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
142 }
143
144 $this->getState()->unlink($this);
145 return $this;
146 }
147
151 public function request(): self
152 {
153 if ($this->getUsrId() === $this->getBuddyUsrId()) {
154 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
155 }
156
157 $this->getState()->request($this);
158 return $this;
159 }
160
164 public function ignore(): self
165 {
166 if ($this->getUsrId() === $this->getBuddyUsrId()) {
167 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
168 }
169
170 $this->getState()->ignore($this);
171 return $this;
172 }
173
174 public function isLinked(): bool
175 {
176 return $this->getState() instanceof ilBuddySystemLinkedRelationState;
177 }
178
179 public function isUnlinked(): bool
180 {
181 return $this->getState() instanceof ilBuddySystemUnlinkedRelationState;
182 }
183
184 public function isRequested(): bool
185 {
186 return $this->getState() instanceof ilBuddySystemRequestedRelationState;
187 }
188
189 public function isIgnored(): bool
190 {
191 return $this->getState() instanceof ilBuddySystemIgnoredRequestRelationState;
192 }
193
194 public function wasLinked(): bool
195 {
196 return $this->getPriorState() instanceof ilBuddySystemLinkedRelationState;
197 }
198
199 public function wasUnlinked(): bool
200 {
201 return $this->getPriorState() instanceof ilBuddySystemUnlinkedRelationState;
202 }
203
204 public function wasRequested(): bool
205 {
206 return $this->getPriorState() instanceof ilBuddySystemRequestedRelationState;
207 }
208
209 public function wasIgnored(): bool
210 {
212 }
213}
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:70
Class ilBuddySystemRelation.
setPriorState(ilBuddySystemRelationState $prior_state)
ilBuddySystemRelationState $state
ilBuddySystemRelationState $priorState
setState(ilBuddySystemRelationState $state, bool $rememberPriorState=true)
withIsOwnedByActor(bool $isOwnedByActor)
__construct(ilBuddySystemRelationState $state, protected int $usrId, protected int $buddyUsrId, protected bool $isOwnedByActor, protected int $timestamp)
Interface ilBuddySystemCollection.
Interface ilBuddySystemRelationState.