ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilBuddySystemRelation.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
11 protected $isOwnedByActor = false;
12
14 protected $usrId;
15
17 protected $buddyUsrId;
18
20 protected $timestamp;
21
23 protected $state;
24
26 protected $priorState;
27
33 {
34 $this->setState($state, false);
35 }
36
42 public function setState(ilBuddySystemRelationState $state, bool $rememberPriorState = true) : self
43 {
44 if ($rememberPriorState) {
45 $this->setPriorState($this->getState());
46 }
47
48 $this->state = $state;
49 return $this;
50 }
51
56 {
57 return $this->state;
58 }
59
64 {
65 return $this->priorState;
66 }
67
72 private function setPriorState(ilBuddySystemRelationState $prior_state) : self
73 {
74 $this->priorState = $prior_state;
75 return $this;
76 }
77
81 public function isOwnedByActor() : bool
82 {
84 }
85
90 public function setIsOwnedByActor(bool $isOwnedByActor) : self
91 {
93 return $this;
94 }
95
99 public function getBuddyUsrId() : int
100 {
101 return $this->buddyUsrId;
102 }
103
108 public function setBuddyUsrId(int $buddyUsrId) : self
109 {
110 $this->buddyUsrId = $buddyUsrId;
111 return $this;
112 }
113
117 public function getUsrId() : int
118 {
119 return $this->usrId;
120 }
121
126 public function setUsrId(int $usrId) : self
127 {
128 $this->usrId = $usrId;
129 return $this;
130 }
131
135 public function getTimestamp() : int
136 {
137 return $this->timestamp;
138 }
139
144 public function setTimestamp(int $timestamp) : self
145 {
146 $this->timestamp = $timestamp;
147 return $this;
148 }
149
154 {
155 return ilBuddySystemRelationStateFilterRuleFactory::getInstance()->getFilterRuleByRelation($this)->getStates();
156 }
157
162 public function link() : self
163 {
164 if ($this->getUsrId() === $this->getBuddyUsrId()) {
165 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
166 }
167
168 $this->getState()->link($this);
169 return $this;
170 }
171
176 public function unlink() : self
177 {
178 if ($this->getUsrId() === $this->getBuddyUsrId()) {
179 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
180 }
181
182 $this->getState()->unlink($this);
183 return $this;
184 }
185
190 public function request() : self
191 {
192 if ($this->getUsrId() === $this->getBuddyUsrId()) {
193 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
194 }
195
196 $this->getState()->request($this);
197 return $this;
198 }
199
204 public function ignore() : self
205 {
206 if ($this->getUsrId() === $this->getBuddyUsrId()) {
207 throw new ilBuddySystemRelationStateException("Can't change a state when the requester equals the requestee.");
208 }
209
210 $this->getState()->ignore($this);
211 return $this;
212 }
213
217 public function isLinked() : bool
218 {
219 return $this->getState() instanceof ilBuddySystemLinkedRelationState;
220 }
221
225 public function isUnlinked() : bool
226 {
227 return $this->getState() instanceof ilBuddySystemUnlinkedRelationState;
228 }
229
233 public function isRequested() : bool
234 {
235 return $this->getState() instanceof ilBuddySystemRequestedRelationState;
236 }
237
241 public function isIgnored() : bool
242 {
243 return $this->getState() instanceof ilBuddySystemIgnoredRequestRelationState;
244 }
245
249 public function wasLinked() : bool
250 {
251 return $this->getPriorState() instanceof ilBuddySystemLinkedRelationState;
252 }
253
257 public function wasUnlinked() : bool
258 {
259 return $this->getPriorState() instanceof ilBuddySystemUnlinkedRelationState;
260 }
261
265 public function wasRequested() : bool
266 {
267 return $this->getPriorState() instanceof ilBuddySystemRequestedRelationState;
268 }
269
273 public function wasIgnored() : bool
274 {
276 }
277}
An exception for terminatinating execution or to throw for unit testing.
Class ilBuddySystemRelation.
setPriorState(ilBuddySystemRelationState $prior_state)
setState(ilBuddySystemRelationState $state, bool $rememberPriorState=true)
setIsOwnedByActor(bool $isOwnedByActor)
__construct(ilBuddySystemRelationState $state)
ilBuddySystemRelation constructor.
Interface ilBuddySystemCollection.
Interface ilBuddySystemRelationState.