ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Online.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\Refinery\Factory as Refinery;
27
31class Online implements Property
32{
33 private const DEFAULT_IS_ONLINE = false;
34 private const INPUT_LABEL = 'online';
35 private const INPUT_BYLINE = 'online_input_byline';
36
37 public function __construct(
38 private bool $is_online = self::DEFAULT_IS_ONLINE
39 ) {
40 }
41
42 public function getIsOnline(): bool
43 {
44 return $this->is_online;
45 }
46
47 public function withOnline(): self
48 {
49 $clone = clone $this;
50 $clone->is_online = true;
51 return $clone;
52 }
53
54 public function withOffline(): self
55 {
56 $clone = clone $this;
57 $clone->is_online = false;
58 return $clone;
59 }
60
61 public function toForm(
62 \ilLanguage $language,
63 FieldFactory $field_factory,
65 ): Checkbox {
66 $trafo = $refinery->custom()->transformation(
67 function ($v): Property {
68 return new self($v);
69 }
70 );
71 return $field_factory->checkbox($language->txt(self::INPUT_LABEL))
72 ->withByline($language->txt(self::INPUT_BYLINE))
74 ->withValue($this->getIsOnline());
75 }
76}
Builds data types.
Definition: Factory.php:36
__construct(private bool $is_online=self::DEFAULT_IS_ONLINE)
Definition: Online.php:37
toForm(\ilLanguage $language, FieldFactory $field_factory, Refinery $refinery)
Definition: Online.php:61
language handling
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes checkbox inputs.
Definition: Checkbox.php:29
This is what a factory for input fields looks like.
Definition: Factory.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withAdditionalTransformation(Transformation $trafo)
@inheritDoc