ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessibilityDocumentCriterionAssignmentConstraint.php
Go to the documentation of this file.
1<?php
2
21
26{
29
30 public function __construct(
33 Factory $dataFactory,
35 ) {
36 $this->criterionTypeFactory = $criterionTypeFactory;
37 $this->document = $document;
38
41 return 0 === count($this->filterEqualValues($value));
42 },
43 function ($txt, $value) {
44 return "The passed assignment must be unique for the document!";
45 },
46 $dataFactory,
47 $lng
48 );
49 }
50
55 protected function filterEqualValues(
57 ): array {
58 $otherValues = $this->document->criteria();
59
60 return array_filter(
61 $otherValues,
62 function (ilAccessibilityDocumentCriterionAssignment $otherValue) use ($value) {
63 $idCurrent = $otherValue->getId();
64 $idNew = $value->getId();
65
66 $uniqueIdEquals = $idCurrent === $idNew;
67 if ($uniqueIdEquals) {
68 return false;
69 }
70
71 $valuesEqual = $value->equals($otherValue);
72 if ($valuesEqual) {
73 return true;
74 }
75
76 $valuesHaveSameNature = $this->haveSameNature($value, $otherValue);
77
78 return $valuesHaveSameNature;
79 }
80 );
81 }
82
86 protected function haveSameNature(
89 ): bool {
90 if ($value->getCriterionId() !== $otherValue->getCriterionId()) {
91 return false;
92 }
93
94 $valuesHaveSameNature = $this->criterionTypeFactory->findByTypeIdent($value->getCriterionId())->hasUniqueNature();
95
96 return $valuesHaveSameNature;
97 }
98}
Builds data types.
Definition: Factory.php:36
ILIAS Language Language $lng
Definition: Constraint.php:37
__construct(ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilAccessibilityDocument $document, Factory $dataFactory, ilLanguage $lng)
haveSameNature(ilAccessibilityDocumentCriterionAssignment $value, ilAccessibilityDocumentCriterionAssignment $otherValue)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
$txt
Definition: error.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
if(!file_exists('../ilias.ini.php'))