ILIAS  release_7 Revision v7.30-3-g800a261c036
ILIAS\Refinery Namespace Reference

Namespaces

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

Data Structures

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

Functions

 applyTo (Result $result)
 
 __invoke ($from)
 
 withProblemBuilder (callable $builder)
 
 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

Function Documentation

◆ __invoke()

ILIAS\Refinery\__invoke (   $from)
Exceptions

Definition at line 26 of file DeriveInvokeFromTransform.php.

27  {
28  return $this->transform($from);
29  }

◆ applyTo()

ILIAS\Refinery\applyTo ( Result  $result)
Parameters
Result$result
Returns
Result

Definition at line 25 of file DeriveApplyToFromTransform.php.

References ILIAS\Data\Result\value().

Referenced by ILIAS\UI\Implementation\Component\Input\Field\Tag\isClientSideValueOk().

25  : Result
26  {
27  try {
28  $value = $this->transform($result->value());
29  } catch (\Exception $exception) {
30  return new Result\Error($exception);
31  }
32 
33  return new Result\Ok($value);
34  }
$result
+ 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.

Returns
string

Definition at line 31 of file ProblemBuilder.php.

References ILIAS\Refinery\getLngClosure().

Referenced by ILIAS\Refinery\Custom\Constraint\check(), ILIAS\Refinery\Custom\Constraint\problemWith(), and ILIAS\Refinery\ByTrying\transform().

32  {
33  $error = $this->getError();
34  if (!is_callable($error)) {
35  return (string) $error;
36  }
37  $lng_closure = $this->getLngClosure();
38  return call_user_func($this->error, $lng_closure, $value);
39  }
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.

Returns

Definition at line 47 of file ProblemBuilder.php.

References $i.

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

48  {
49  return function () {
50  $args = func_get_args();
51  if (count($args) < 1) {
52  throw new \InvalidArgumentException(
53  "Expected an id of a lang var as first parameter"
54  );
55  }
56  $error = $this->lng->txt($args[0]);
57  if (count($args) > 1) {
58  $args[0] = $error;
59  for ($i = 0; $i < count($args); $i++) {
60  $v = $args[$i];
61  if ((is_array($v) || is_object($v) || is_null($v))
62  && !method_exists($v, "__toString")) {
63  if (is_array($v)) {
64  $args[$i] = "array";
65  } elseif (is_null($v)) {
66  $args[$i] = "null";
67  } else {
68  $args[$i] = get_class($v);
69  }
70  }
71  }
72  $error = call_user_func_array("sprintf", $args);
73  }
74  return $error;
75  };
76  }
$i
Definition: metadata.php:24
+ Here is the caller graph for this function:

◆ withProblemBuilder()

ILIAS\Refinery\withProblemBuilder ( callable  $builder)
final

Definition at line 19 of file ProblemBuilder.php.

References $builder.

Referenced by ILIAS\UI\Implementation\Component\Input\Field\Tag\getConstraintForRequirement().

20  {
21  $clone = clone $this;
22  $clone->error = $builder;
23  return $clone;
24  }
$builder
Definition: parser.php:5
+ Here is the caller graph for this function:

Variable Documentation

◆ DeriveApplyToFromTransform

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

Definition at line 13 of file DeriveApplyToFromTransform.php.

◆ DeriveInvokeFromTransform

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

Definition at line 13 of file DeriveInvokeFromTransform.php.

◆ DeriveTransformFromApplyTo

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

Definition at line 13 of file DeriveTransformFromApplyTo.php.

◆ ProblemBuilder

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

Definition at line 10 of file ProblemBuilder.php.