ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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
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...
 
 withProblemBuilder (callable $builder)
 Get a constraint like this one with a builder for a custom error message.problemWith() must return an error message according to the new builder for the new constraint.The builder needs to be callable that takes two parameters:
Parameters
callable$builder
Returns
Constraint
More...
 
 getErrorMessage ($value)
 Get the problem 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
 getLngClosure ()
 Get the closure to be passed to the error-function that does i18n and sprintf. More...
 

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.

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

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)
+ 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.

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

Referenced by __construct().

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)
+ 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.

References ilTermsOfServiceDocumentCriterionAssignment\getCriterionId().

Referenced by filterEqualValues().

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  }
+ Here is the call graph for this function:
+ 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: