ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint Class Reference
+ Inheritance diagram for ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint:
+ Collaboration diagram for ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint:

Public Member Functions

 __construct (callable $is_ok, $error, Data\Factory $data_factory, \ILIAS\Language\Language $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

 getError ()
 

Protected Attributes

Data Factory $data_factory
 
ILIAS Language Language $lng
 
 $is_ok
 
 $error
 

Detailed Description

Definition at line 30 of file Constraint.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::__construct ( callable  $is_ok,
  $error,
Data\Factory  $data_factory,
\ILIAS\Language\Language  $lng 
)

If $error is a callable it needs to take two parameters:

  • one callback $txt($lng_id, ($value, ...)) that retrieves the lang var with the given id and uses sprintf to replace placeholder if more values are provide.
  • the $value for which the error message should be build.
Parameters
callable$is_ok
string | callable$error
Data\Factory$data_factory
\ILIAS\Language\Language$lng

Definition at line 55 of file Constraint.php.

References ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\$data_factory, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\$error, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\$is_ok, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\$lng, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ accepts()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::accepts (   $value)
final

Implements ILIAS\Refinery\Constraint.

Definition at line 86 of file Constraint.php.

Referenced by ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\check(), and ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\problemWith().

86  : bool
87  {
88  return call_user_func($this->is_ok, $value);
89  }
+ Here is the caller graph for this function:

◆ applyTo()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::applyTo ( Result  $result)
final

Implements ILIAS\Refinery\Constraint.

Definition at line 106 of file Constraint.php.

References ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\$error, ILIAS\Data\Result\isError(), null, ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\problemWith(), and ILIAS\Data\Result\value().

106  : Result
107  {
108  if ($result->isError()) {
109  return $result;
110  }
111 
112  $problem = $this->problemWith($result->value());
113  if ($problem !== null) {
114  $error = $this->data_factory->error($problem);
115  return $error;
116  }
117 
118  return $result;
119  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ check()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::check (   $value)
final

Implements ILIAS\Refinery\Constraint.

Definition at line 74 of file Constraint.php.

References ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\accepts(), ILIAS\Refinery\getErrorMessage(), and null.

75  {
76  if (!$this->accepts($value)) {
77  throw new \UnexpectedValueException($this->getErrorMessage($value));
78  }
79 
80  return null;
81  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getErrorMessage($value)
+ Here is the call graph for this function:

◆ getError()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::getError ( )
protected

◆ problemWith()

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::problemWith (   $value)
final

Implements ILIAS\Refinery\Constraint.

Definition at line 94 of file Constraint.php.

References ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\accepts(), ILIAS\Refinery\getErrorMessage(), and null.

Referenced by ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\applyTo().

94  : ?string
95  {
96  if (!$this->accepts($value)) {
97  return $this->getErrorMessage($value);
98  }
99 
100  return null;
101  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getErrorMessage($value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data_factory

Data Factory ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::$data_factory
protected

◆ $error

◆ $is_ok

ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint::$is_ok
protected

◆ $lng


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