ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAccessibilityDocumentCriterionAssignmentConstraint.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
6 
11 {
14 
16  protected $document;
17 
25  public function __construct(
28  Factory $dataFactory,
30  ) {
31  $this->criterionTypeFactory = $criterionTypeFactory;
32  $this->document = $document;
33 
36  return 0 === count($this->filterEqualValues($value));
37  },
38  function ($txt, $value) {
39  return "The passed assignment must be unique for the document!";
40  },
41  $dataFactory,
42  $lng
43  );
44  }
45 
50  protected function filterEqualValues(
52  ) : array {
53  $otherValues = $this->document->criteria();
54 
55  return array_filter(
56  $otherValues,
57  function (ilAccessibilityDocumentCriterionAssignment $otherValue) use ($value) {
58  $idCurrent = $otherValue->getId();
59  $idNew = $value->getId();
60 
61  $uniqueIdEquals = $idCurrent === $idNew;
62  if ($uniqueIdEquals) {
63  return false;
64  }
65 
66  $valuesEqual = $value->equals($otherValue);
67  if ($valuesEqual) {
68  return true;
69  }
70 
71  $valuesHaveSameNature = $this->haveSameNature($value, $otherValue);
72 
73  return $valuesHaveSameNature;
74  }
75  );
76  }
77 
84  protected function haveSameNature(
87  ) : bool {
88  if ($value->getCriterionId() !== $otherValue->getCriterionId()) {
89  return false;
90  }
91 
92  $valuesHaveSameNature = $this->criterionTypeFactory->findByTypeIdent($value->getCriterionId())->hasUniqueNature();
93 
94  return $valuesHaveSameNature;
95  }
96 }
haveSameNature(ilAccessibilityDocumentCriterionAssignment $value, ilAccessibilityDocumentCriterionAssignment $otherValue)
Class ilAccessibilityDocument.
__construct(ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilAccessibilityDocument $document, Factory $dataFactory, ilLanguage $lng)
ilAccessibilityDocumentCriterionAssignmentConstraint constructor.
Builds data types.
Definition: Factory.php:19
$txt
Definition: error.php:13
__construct(Container $dic, ilPlugin $plugin)
language handling