ILIAS  release_8 Revision v8.24
ILIAS\Refinery Namespace Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

Namespaces

namespace  Container
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Custom
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  DateTime
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  In
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Integer
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  KindlyTo
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Logical
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Numeric
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Password
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  Random
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  String
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  To
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 
namespace  URI
 This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
 

Data Structures

class  ByTrying
 
class  ConstantTransformation
 
interface  Constraint
 A constraint encodes some resrtictions on values. More...
 
class  ConstraintViolationException
 
class  Factory
 
class  IdentityTransformation
 
class  IsNull
 
class  KeyValueAccess
 
interface  Transformation
 A transformation is a function from one datatype to another. More...
 

Functions

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

Variables

trait DeriveApplyToFromTransform
 
trait DeriveInvokeFromTransform
 
trait DeriveTransformFromApplyTo
 
trait ProblemBuilder
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Function Documentation

◆ __invoke()

ILIAS\Refinery\__invoke (   $from)

@inheritDoc

Definition at line 36 of file DeriveInvokeFromTransform.php.

37 {
38 return $this->transform($from);
39 }

Referenced by ilInitialisation\getClientIdTransformation().

+ Here is the caller graph for this function:

◆ applyTo()

ILIAS\Refinery\applyTo ( Result  $result)

@inheritDoc

Definition at line 38 of file DeriveApplyToFromTransform.php.

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 }
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:17
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:15
then(callable $f)
Get a new result from the callable or do nothing if this is an error.

References ILIAS\Data\Result\then().

Referenced by ilInitialisation\getClientIdTransformation(), ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToError(), and ILIAS\Tests\Refinery\IdentityTransformationTest\testApplyToOk().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getErrorMessage()

ILIAS\Refinery\getErrorMessage (   $value)
final

Get the problem message.

Parameters
mixed$value
Returns
string

Definition at line 48 of file ProblemBuilder.php.

48 : string
49 {
50 $error = $this->getError();
51 if (!is_callable($error)) {
52 return $error;
53 }
54 $lng_closure = $this->getLngClosure();
55 return call_user_func($this->error, $lng_closure, $value);
56 }
getError()
error(string $a_errmsg)
getLngClosure()
Get the closure to be passed to the error-function that does i18n and sprintf.

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

Referenced by assTextQuestionGUI\addSuggestedSolution(), ILIAS\Refinery\Custom\Constraint\check(), ILIAS\Refinery\To\Transformation\BooleanTransformation\check(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\check(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\check(), ILIAS\Refinery\To\Transformation\FloatTransformation\check(), ILIAS\Refinery\To\Transformation\IntegerTransformation\check(), ILIAS\Refinery\To\Transformation\ListTransformation\check(), ILIAS\Refinery\To\Transformation\RecordTransformation\check(), ILIAS\Refinery\To\Transformation\StringTransformation\check(), ILIAS\Refinery\To\Transformation\TupleTransformation\check(), ILIAS\Refinery\Custom\Constraint\problemWith(), ILIAS\Refinery\To\Transformation\BooleanTransformation\problemWith(), ILIAS\Refinery\To\Transformation\DateTimeTransformation\problemWith(), ILIAS\Refinery\To\Transformation\DictionaryTransformation\problemWith(), ILIAS\Refinery\To\Transformation\FloatTransformation\problemWith(), ILIAS\Refinery\To\Transformation\IntegerTransformation\problemWith(), ILIAS\Refinery\To\Transformation\ListTransformation\problemWith(), ILIAS\Refinery\To\Transformation\RecordTransformation\problemWith(), ILIAS\Refinery\To\Transformation\StringTransformation\problemWith(), ILIAS\Refinery\To\Transformation\TupleTransformation\problemWith(), and ILIAS\Refinery\ByTrying\transform().

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

Returns
Closure

Definition at line 62 of file ProblemBuilder.php.

62 : Closure
63 {
64 return function () {
65 $args = func_get_args();
66 if (count($args) < 1) {
67 throw new InvalidArgumentException(
68 "Expected an id of a lang var as first parameter"
69 );
70 }
71
72 $error = $this->lng->txt($args[0]);
73 if (count($args) > 1) {
74 $args[0] = $error;
75 for ($i = 0, $numArgs = count($args); $i < $numArgs; $i++) {
76 $v = $args[$i];
77 if (is_array($v) || is_null($v) || (is_object($v) && !method_exists($v, "__toString"))) {
78 if (is_array($v)) {
79 $args[$i] = "array";
80 } elseif (is_null($v)) {
81 $args[$i] = "null";
82 } else {
83 $args[$i] = get_class($v);
84 }
85 }
86 }
87 $error = sprintf(...$args);
88 }
89
90 return $error;
91 };
92 }
$i
Definition: metadata.php:41

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

Referenced by MyValidationConstraintsConstraint\_getLngClosure(), and ILIAS\Refinery\getErrorMessage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ withProblemBuilder()

ILIAS\Refinery\withProblemBuilder ( callable  $builder)
final

@inheritDoc

Definition at line 36 of file ProblemBuilder.php.

36 : self
37 {
38 $clone = clone $this;
39 $clone->error = $builder;
40 return $clone;
41 }

Variable Documentation

◆ DeriveApplyToFromTransform

trait ILIAS::Refinery\DeriveApplyToFromTransform
Initial value:
{
abstract public function transform($from)

Definition at line 28 of file DeriveApplyToFromTransform.php.

◆ DeriveInvokeFromTransform

trait ILIAS::Refinery\DeriveInvokeFromTransform
Initial value:
{
abstract public function transform($from)

Definition at line 26 of file DeriveInvokeFromTransform.php.

◆ DeriveTransformFromApplyTo

trait ILIAS::Refinery\DeriveTransformFromApplyTo
Initial value:
{
abstract public function applyTo(Result $result): Result
applyTo(Result $result)
@inheritDoc

Definition at line 26 of file DeriveTransformFromApplyTo.php.

◆ ProblemBuilder

trait ILIAS::Refinery\ProblemBuilder
Initial value:
{
abstract protected function getError()

Definition at line 26 of file ProblemBuilder.php.