ILIAS  release_7 Revision v7.30-3-g800a261c036
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}
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
__construct(ilAccessibilityCriterionTypeFactoryInterface $criterionTypeFactory, ilAccessibilityDocument $document, Factory $dataFactory, ilLanguage $lng)
ilAccessibilityDocumentCriterionAssignmentConstraint constructor.
haveSameNature(ilAccessibilityDocumentCriterionAssignment $value, ilAccessibilityDocumentCriterionAssignment $otherValue)
Class ilAccessibilityDocument.
language handling
if(!file_exists(getcwd() . '/ilias.ini.php'))
registration confirmation script for ilias
Definition: confirmReg.php:12
$txt
Definition: error.php:13
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc