ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Refinery Namespace Reference

Namespaces

 Container
 
 Custom
 
 DateTime
 
 Encode
 
 In
 
 Integer
 
 KindlyTo
 
 Logical
 
 Numeric
 
 Parser
 
 Password
 
 Random
 
 String
 
 To
 
 URI
 

Functions

 applyTo (Result $result)
 
 __invoke ($from)
 
 transform ($from)
 
 check ($value)
 
 problemWith ($value)
 
 withProblemBuilder (callable $builder)
 
 getErrorMessage ($value)
 
 getLngClosure ()
 Get the closure to be passed to the error-function that does i18n and sprintf. More...
 

Function Documentation

◆ __invoke()

ILIAS\Refinery\__invoke (   $from)

Definition at line 33 of file DeriveInvokeFromTransform.php.

References ILIAS\Refinery\transform().

Referenced by ilInitialisation\getClientIdTransformation().

34  {
35  return $this->transform($from);
36  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyTo()

ILIAS\Refinery\applyTo ( Result  $result)

Definition at line 38 of file DeriveApplyToFromTransform.php.

References ILIAS\Data\Result\then(), and ILIAS\Refinery\transform().

Referenced by ilInitialisation\getClientIdTransformation(), ILIAS\UI\Implementation\Component\Input\Field\Tag\isClientSideValueOk(), ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToError(), and ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToOk().

38  : Result
39  {
40  return $result->then(function ($value): Result {
41  try {
42  return new Ok($this->transform($value));
43  } catch (Exception $exception) {
44  return new Error($exception);
45  }
46  });
47  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check()

ILIAS\Refinery\check (   $value)

Definition at line 42 of file DeriveTransformWithProblem.php.

References ILIAS\Refinery\getErrorMessage().

Referenced by ILIAS\ResourceStorage\Policy\FileNamePolicyTest\getFileNamePolicy(), and ILIAS\Refinery\transform().

43  {
44  if (!$this->accepts($value)) {
45  throw new UnexpectedValueException($this->getErrorMessage($value));
46  }
47  }
getErrorMessage($value)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorMessage()

ILIAS\Refinery\getErrorMessage (   $value)
final

Definition at line 39 of file ProblemBuilder.php.

References ILIAS\$error, and ILIAS\Refinery\getLngClosure().

Referenced by ILIAS\Refinery\check(), ILIAS\Refinery\To\Transformation\StringTransformation\check(), ILIAS\Refinery\To\Transformation\BooleanTransformation\check(), ILIAS\Refinery\To\Transformation\FloatTransformation\check(), ILIAS\Refinery\To\Transformation\IntegerTransformation\check(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\check(), ILIAS\Refinery\To\Transformation\ListTransformation\check(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\check(), ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\check(), ILIAS\Refinery\To\Transformation\TupleTransformation\check(), ILIAS\Refinery\To\Transformation\RecordTransformation\check(), ILIAS\Refinery\problemWith(), ILIAS\Refinery\To\Transformation\IntegerTransformation\problemWith(), ILIAS\Refinery\To\Transformation\BooleanTransformation\problemWith(), ILIAS\Refinery\To\Transformation\StringTransformation\problemWith(), ILIAS\Refinery\To\Transformation\FloatTransformation\problemWith(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\problemWith(), ILIAS\Refinery\To\Transformation\ListTransformation\problemWith(), ILIAS\AdvancedMetaData\Services\ObjectModes\Custom\Custom\Constraint\problemWith(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\problemWith(), ILIAS\Refinery\To\Transformation\TupleTransformation\problemWith(), ILIAS\Refinery\To\Transformation\RecordTransformation\problemWith(), ilObjPrivacySecurityGUI\save_privacy(), and ILIAS\Refinery\ByTrying\transform().

39  : string
40  {
41  $error = $this->getError();
42  if (!is_callable($error)) {
43  return $error;
44  }
45  $lng_closure = $this->getLngClosure();
46  return $error($lng_closure, $value);
47  }
getLngClosure()
Get the closure to be passed to the error-function that does i18n and sprintf.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLngClosure()

ILIAS\Refinery\getLngClosure ( )
finalprotected

Get the closure to be passed to the error-function that does i18n and sprintf.

Definition at line 52 of file ProblemBuilder.php.

References ILIAS\$error, and ILIAS\Repository\lng().

Referenced by ILIAS\Refinery\getErrorMessage(), and CustomTest\setUp().

52  : Closure
53  {
54  return function (string $lang_var, ...$args): string {
55  $error = $this->lng->txt($lang_var);
56 
57  if ($args === []) {
58  return $error;
59  }
60 
61  return sprintf($error, ...array_map(function ($v) {
62  if (is_array($v)) {
63  return "array";
64  } elseif (is_null($v)) {
65  return "null";
66  } elseif (is_object($v) && !method_exists($v, "__toString")) {
67  return get_class($v);
68  }
69  return $v;
70  }, $args));
71  };
72  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ problemWith()

ILIAS\Refinery\problemWith (   $value)

Definition at line 49 of file DeriveTransformWithProblem.php.

References ILIAS\Refinery\getErrorMessage(), and null.

49  : ?string
50  {
51  if (!$this->accepts($value)) {
52  return $this->getErrorMessage($value);
53  }
54 
55  return null;
56  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getErrorMessage($value)
+ Here is the call graph for this function:

◆ transform()

ILIAS\Refinery\transform (   $from)

Definition at line 36 of file DeriveTransformWithProblem.php.

References ILIAS\Refinery\check().

Referenced by ILIAS\Refinery\Parser\ABNF\Brick\__construct(), ilObjectServiceSettingsGUI\__construct(), ilLDAPSettingsGUI\__construct(), ILIAS\Refinery\__invoke(), ILIAS\Refinery\applyTo(), ilObjectGUI\buildRefIdsFromData(), ilMailSearchObjectGUI\cancel(), ILIAS\TestQuestionPool\ilTestLegacyFormsHelper\checkPointsInput(), ilMailTemplateGUI\confirmDeleteTemplate(), ilRegistrationSettingsGUI\deleteConfirmation(), ilRegistrationSettingsGUI\exportCodes(), ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\getAnswerDetail(), ilInitialisation\getClientIdTransformation(), ILIAS\TestQuestionPool\RequestDataCollector\getMatchingPairs(), ilObjUserFolderGUI\importUsersObject(), ilMailExplorer\initFolder(), ilMailGUI\initFolder(), ilMailFolderGUI\initRequest(), ilChatroomViewGUI\lostConnection(), ILIAS\Refinery\Parser\ABNF\Brick\namesFromKeys(), ilMailCronOrphanedMails\saveCustomSettings(), ilForumCronNotification\saveCustomSettings(), ILIAS\ILIASObject\Properties\MultiPropertiesManipulator\saveEditAvailabilityPeriodPropertiesModal(), ILIAS\Test\Scoring\Manual\TestScoringByQuestionGUI\saveManScoringByQuestion(), ILIAS\Test\Scoring\Manual\TestScoringByParticipantGUI\saveManScoringParticipantScreen(), ilObjectCopyGUI\setSource(), ilObjectCopyGUI\setTargets(), ilMailFormGUI\showForm(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\JsonTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testInvalidEncoding(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testInvalidType(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testInvalidType(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testInvalidType(), ILIAS\Tests\Refinery\ConstantTransformationTest\testTransform(), ILIAS\Tests\Refinery\IdentityTransformationTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\URLTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLSpecialCharsAsEntitiesTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\JsonTest\testTransform(), ILIAS\Tests\Refinery\Encode\Transformation\HTMLAttributeValueTest\testTransform(), ILIAS\Tests\Refinery\Random\Transformation\ShuffleTransformationTest\testTransformResultFailure(), ILIAS\Tests\Refinery\Random\Transformation\ShuffleTransformationTest\testTransformResultSuccess(), assFormulaQuestionResult\transformAnswerValueAccordingToType(), ILIAS\TestQuestionPool\ilTestLegacyFormsHelper\transformArray(), ILIAS\Refinery\Parser\ABNF\Brick\transformation(), and ILIAS\TestQuestionPool\ilTestLegacyFormsHelper\transformPoints().

37  {
38  $this->check($from);
39  return $from;
40  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withProblemBuilder()