ILIAS  release_7 Revision v7.30-3-g800a261c036
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)
 ilTermsOfServiceDocumentCriterionAssignmentConstraint constructor. More...
 
- 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)
 Checks the provided value.Should not throw if accepts($value).
Exceptions

UnexpectedValueException if value does not comply with encoded constraint.

Parameters
mixed$value
Returns
null
More...
 
 accepts ($value)
 Tells if the provided value complies.
Parameters
mixed$value
Returns
bool
More...
 
 problemWith ($value)
 Tells what the problem with the provided value is.Should return null if accepts($value).
Parameters
mixed$value
Returns
string|null
More...
 
 applyTo (Result $result)
 Restricts a Result.Must do nothing with the result if $result->isError(). Must replace the result with an error according to problemWith() if !accepts($result->value()).
Parameters
Result$result
Returns
Result
More...
 
- Public Member Functions inherited from ILIAS\Refinery\Constraint
 check ($value)
 Checks the provided value. More...
 
 accepts ($value)
 Tells if the provided value complies. More...
 
 problemWith ($value)
 Tells what the problem with the provided value is. More...
 
 applyTo (Result $result)
 Restricts a Result. More...
 
 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...
 
 applyTo (Result $data)
 Perform the transformation and reify possible failures. 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

 $criterionTypeFactory
 
 $document
 
- Protected Attributes inherited from ILIAS\Refinery\Custom\Constraint
 $data_factory
 
 $lng
 
 $is_ok
 
 $error
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

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

ilTermsOfServiceDocumentCriterionAssignmentConstraint constructor.

Parameters
ilTermsOfServiceCriterionTypeFactoryInterface$criterionTypeFactory
ilTermsOfServiceDocument$document
Factory$dataFactory
ilLanguage$lng

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

31 {
32 $this->criterionTypeFactory = $criterionTypeFactory;
33 $this->document = $document;
34
37 return 0 === count($this->filterEqualValues($value));
38 },
39 function ($txt, $value) {
40 return "The passed assignment must be unique for the document!";
41 },
42 $dataFactory,
43 $lng
44 );
45 }
$txt
Definition: error.php:13
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ 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 51 of file class.ilTermsOfServiceDocumentCriterionAssignmentConstraint.php.

53 : array {
54 $otherValues = $this->document->criteria();
55
56 return array_filter(
57 $otherValues,
58 function (ilTermsOfServiceDocumentCriterionAssignment $otherValue) use ($value) {
59 $idCurrent = $otherValue->getId();
60 $idNew = $value->getId();
61
62 $uniqueIdEquals = $idCurrent === $idNew;
63 if ($uniqueIdEquals) {
64 return false;
65 }
66
67 $valuesEqual = $value->equals($otherValue);
68 if ($valuesEqual) {
69 return true;
70 }
71
72 $valuesHaveSameNature = $this->haveSameNature($value, $otherValue);
73
74 return $valuesHaveSameNature;
75 }
76 );
77 }
haveSameNature(ilTermsOfServiceDocumentCriterionAssignment $value, ilTermsOfServiceDocumentCriterionAssignment $otherValue)

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

Referenced by __construct().

+ 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 85 of file class.ilTermsOfServiceDocumentCriterionAssignmentConstraint.php.

88 : bool {
89 if ($value->getCriterionId() !== $otherValue->getCriterionId()) {
90 return false;
91 }
92
93 $valuesHaveSameNature = $this->criterionTypeFactory->findByTypeIdent($value->getCriterionId())->hasUniqueNature();
94
95 return $valuesHaveSameNature;
96 }

Referenced by filterEqualValues().

+ Here is the caller graph for this function:

Field Documentation

◆ $criterionTypeFactory

ilTermsOfServiceDocumentCriterionAssignmentConstraint::$criterionTypeFactory
protected

◆ $document

ilTermsOfServiceDocumentCriterionAssignmentConstraint::$document
protected

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