97 return self::TABLE_NAME;
119 public function id() : int
131 $this->fetchAllCriterionAssignments();
139 $document = parent::buildFromArray($array);
141 $this->fetchAllCriterionAssignments();
151 $this->setCreationTs(time());
155 foreach ($this->
criteria as $criterionAssignment) {
157 $criterionAssignment->setDocId($this->getId());
158 $criterionAssignment->store();
169 $this->setModificationTs(time());
171 foreach ($this->
criteria as $criterionAssignment) {
173 $criterionAssignment->setDocId($this->getId());
174 $criterionAssignment->store();
177 foreach ($this->initialPersistedCriteria as $criterionAssignment) {
180 return $criterionToMatch->getId() == $criterionAssignment->getId();
183 if (0 ===
count($found)) {
184 $criterionAssignment->delete();
197 public function delete()
199 foreach ($this->initialPersistedCriteria as $criterionAssignment) {
201 $criterionAssignment->delete();
204 $this->initialPersistedCriteria = $this->
criteria = [];
223 foreach ($this->
criteria as $currentAssignment) {
225 if ($currentAssignment->equals($criterionAssignment)) {
226 throw new \ilTermsOfServiceDuplicateCriterionAssignmentException(sprintf(
227 "Cannot attach duplicate criterion with criterion typeIdent %s and value: %s",
234 $this->
criteria[] = $criterionAssignment;
246 return !$currentAssignment->
equals($criterionAssignment);
251 if ($numCriteriaAfterRemoval === $numCriteriaBeforeRemoval) {
252 throw new \OutOfBoundsException(sprintf(
253 "Could not find any criterion with criterion typeIdent %s and value: %s",
263 public function fetchAllCriterionAssignments()
265 if (!$this->criteriaFetched) {
266 $this->criteriaFetched =
true;
268 $this->initialPersistedCriteria = [];
272 foreach (
$criteria as $criterionAssignment) {
274 $this->
criteria[] = $criterionAssignment;
$initialPersistedCriteria
detachCriterion(\ilTermsOfServiceDocumentCriterionAssignment $criterionAssignment)
buildFromArray(array $array)
static where($where, $operator=null)
Class ilTermsOfServiceDocumentCriterionAssignment.
Class ilTermsOfServiceDocument.
update($pash, $contents, Config $config)
static returnDbTableName()
Interface ilTermsOfServiceSignableDocument.