ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAccessibilityDocumentCriterionAssignmentConstraint.php
Go to the documentation of this file.
1 <?php
2 
21 
26 {
29 
30  public function __construct(
32  ilAccessibilityDocument $document,
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 }
haveSameNature(ilAccessibilityDocumentCriterionAssignment $value, ilAccessibilityDocumentCriterionAssignment $otherValue)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilAccessibilityDocument $document, Factory $dataFactory, ilLanguage $lng)
$txt
Definition: error.php:13
__construct(Container $dic, ilPlugin $plugin)
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...