ILIAS  release_8 Revision v8.23
ilTermsOfServiceDocumentCriterionAssignmentConstraint Class Reference

Class ilTermsOfServiceDocumentCriterionAssignmentConstraint. More...

+ Inheritance diagram for ilTermsOfServiceDocumentCriterionAssignmentConstraint:
+ Collaboration diagram for ilTermsOfServiceDocumentCriterionAssignmentConstraint:

Public Member Functions

 __construct (ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory, ilTermsOfServiceDocument $document, Factory $dataFactory, ilLanguage $lng)
 
- Public Member Functions inherited from ILIAS\Refinery\Custom\Constraint
 __construct (callable $is_ok, $error, Data\Factory $data_factory, ilLanguage $lng)
 If $error is a callable it needs to take two parameters: More...
 
 check ($value)
 
 accepts ($value)
 
 problemWith ($value)
 
 applyTo (Result $result)
 
- Public Member Functions inherited from ILIAS\Refinery\Constraint
 withProblemBuilder (callable $builder)
 Get a constraint like this one with a builder for a custom error message. More...
 
- Public Member Functions inherited from ILIAS\Refinery\Transformation
 transform ($from)
 Perform the transformation. More...
 
 __invoke ($from)
 Transformations should be callable. More...
 

Protected Member Functions

 filterEqualValues (ilTermsOfServiceDocumentCriterionAssignment $value)
 
 haveSameNature (ilTermsOfServiceDocumentCriterionAssignment $value, ilTermsOfServiceDocumentCriterionAssignment $otherValue)
 
- Protected Member Functions inherited from ILIAS\Refinery\Custom\Constraint
 getError ()
 

Protected Attributes

ilTermsOfServiceCriterionTypeFactoryInterface $criterionTypeFactory
 
ilTermsOfServiceDocument $document
 
- Protected Attributes inherited from ILIAS\Refinery\Custom\Constraint
Data Factory $data_factory
 
ilLanguage $lng
 
 $is_ok
 
 $error
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilTermsOfServiceDocumentCriterionAssignmentConstraint::__construct ( ilTermsOfServiceCriterionTypeFactoryInterface  $criterionTypeFactory,
ilTermsOfServiceDocument  $document,
Factory  $dataFactory,
ilLanguage  $lng 
)

Definition at line 33 of file class.ilTermsOfServiceDocumentCriterionAssignmentConstraint.php.

References $criterionTypeFactory, $document, ILIAS\Refinery\Custom\Constraint\$lng, $txt, ILIAS\GlobalScreen\Provider\__construct(), and filterEqualValues().

38  {
39  $this->criterionTypeFactory = $criterionTypeFactory;
40  $this->document = $document;
41 
43  function (ilTermsOfServiceDocumentCriterionAssignment $value): bool {
44  return 0 === count($this->filterEqualValues($value));
45  },
46  static function ($txt, $value): string {
47  return 'The passed assignment must be unique for the document!';
48  },
49  $dataFactory,
50  $lng
51  );
52  }
$txt
Definition: error.php:13
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ filterEqualValues()

ilTermsOfServiceDocumentCriterionAssignmentConstraint::filterEqualValues ( ilTermsOfServiceDocumentCriterionAssignment  $value)
protected
Parameters
ilTermsOfServiceDocumentCriterionAssignment$value
Returns
ilTermsOfServiceDocumentCriterionAssignment[]|ilTermsOfServiceEvaluableCriterion[]

Definition at line 58 of file class.ilTermsOfServiceDocumentCriterionAssignmentConstraint.php.

References ilTermsOfServiceDocumentCriterionAssignment\equals(), and haveSameNature().

Referenced by __construct().

60  : array {
61  $otherValues = $this->document->criteria();
62 
63  return array_filter(
64  $otherValues,
65  function (ilTermsOfServiceDocumentCriterionAssignment $otherValue) use ($value): bool {
66  $idCurrent = $otherValue->getId();
67  $idNew = $value->getId();
68 
69  $uniqueIdEquals = $idCurrent === $idNew;
70  if ($uniqueIdEquals) {
71  return false;
72  }
73 
74  $valuesEqual = $value->equals($otherValue);
75  if ($valuesEqual) {
76  return true;
77  }
78 
79  return $this->haveSameNature($value, $otherValue);
80  }
81  );
82  }
haveSameNature(ilTermsOfServiceDocumentCriterionAssignment $value, ilTermsOfServiceDocumentCriterionAssignment $otherValue)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ haveSameNature()

ilTermsOfServiceDocumentCriterionAssignmentConstraint::haveSameNature ( ilTermsOfServiceDocumentCriterionAssignment  $value,
ilTermsOfServiceDocumentCriterionAssignment  $otherValue 
)
protected
Parameters
ilTermsOfServiceDocumentCriterionAssignment$value
ilTermsOfServiceDocumentCriterionAssignment$otherValue
Returns
bool
Exceptions
ilTermsOfServiceCriterionTypeNotFoundException

Definition at line 90 of file class.ilTermsOfServiceDocumentCriterionAssignmentConstraint.php.

References ilTermsOfServiceDocumentCriterionAssignment\getCriterionId().

Referenced by filterEqualValues().

93  : bool {
94  if ($value->getCriterionId() !== $otherValue->getCriterionId()) {
95  return false;
96  }
97 
98  $valuesHaveSameNature = $this->criterionTypeFactory->findByTypeIdent($value->getCriterionId())->hasUniqueNature();
99 
100  return $valuesHaveSameNature;
101  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $criterionTypeFactory

ilTermsOfServiceCriterionTypeFactoryInterface ilTermsOfServiceDocumentCriterionAssignmentConstraint::$criterionTypeFactory
protected

◆ $document

ilTermsOfServiceDocument ilTermsOfServiceDocumentCriterionAssignmentConstraint::$document
protected

The documentation for this class was generated from the following file: