ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
Online.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
31 class 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 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This describes checkbox inputs.
Definition: Checkbox.php:28
toForm(\ilLanguage $language, FieldFactory $field_factory, Refinery $refinery)
Definition: Online.php:61
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(private bool $is_online=self::DEFAULT_IS_ONLINE)
Definition: Online.php:37