ILIAS  release_8 Revision v8.23
ilStudyProgrammeDeadlineSettings Class Reference
+ Collaboration diagram for ilStudyProgrammeDeadlineSettings:

Public Member Functions

 __construct (?int $deadline_period, ?DateTimeImmutable $deadline_date)
 
 getDeadlinePeriod ()
 
 withDeadlinePeriod (?int $deadline_period)
 
 getDeadlineDate ()
 
 withDeadlineDate (?DateTimeImmutable $deadline_date)
 
 toFormInput (Field\Factory $input, ilLanguage $lng, Refinery $refinery, Factory $data_factory)
 

Protected Attributes

int $deadline_period
 
DateTimeImmutable $deadline_date
 

Detailed Description

Definition at line 25 of file class.ilStudyProgrammeDeadlineSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeDeadlineSettings::__construct ( ?int  $deadline_period,
?DateTimeImmutable  $deadline_date 
)

Definition at line 30 of file class.ilStudyProgrammeDeadlineSettings.php.

References $deadline_date, and $deadline_period.

31  {
32  if (!is_null($deadline_period) && 0 > $deadline_period) {
33  throw new InvalidArgumentException('Numbers less than 0 are not allowed');
34  }
35 
36  $this->deadline_period = $deadline_period;
37  $this->deadline_date = $deadline_date;
38  }

Member Function Documentation

◆ getDeadlineDate()

ilStudyProgrammeDeadlineSettings::getDeadlineDate ( )

Definition at line 56 of file class.ilStudyProgrammeDeadlineSettings.php.

References $deadline_date.

Referenced by toFormInput(), and updateProgressDeadlineFromSettings().

+ Here is the caller graph for this function:

◆ getDeadlinePeriod()

ilStudyProgrammeDeadlineSettings::getDeadlinePeriod ( )

Definition at line 40 of file class.ilStudyProgrammeDeadlineSettings.php.

References $deadline_period.

Referenced by toFormInput(), and updateProgressDeadlineFromSettings().

+ Here is the caller graph for this function:

◆ toFormInput()

ilStudyProgrammeDeadlineSettings::toFormInput ( Field\Factory  $input,
ilLanguage  $lng,
Refinery  $refinery,
Factory  $data_factory 
)

Definition at line 68 of file class.ilStudyProgrammeDeadlineSettings.php.

References $format, ILIAS\Data\Factory\dateFormat(), getDeadlineDate(), getDeadlinePeriod(), ILIAS\Repository\int(), ilLanguage\txt(), ILIAS\UI\Implementation\Component\Input\ViewControl\withAdditionalTransformation(), and ILIAS\UI\Implementation\Component\Input\withValue().

74  $format = $data_factory->dateFormat()->germanShort();
75 
76  $grp1 = $input->group([], $lng->txt('prg_no_deadline'));
77  $grp2 = $input->group(
78  [
79  'deadline_period' => $input->numeric(
80  $lng->txt('prg_deadline_period_label'),
81  $lng->txt('prg_deadline_period_desc')
82  )
83  ->withAdditionalTransformation($refinery->int()->isGreaterThanOrEqual(1))
84  ->withValue($this->getDeadlinePeriod())
85  ->withRequired(true)
86  ],
87  $lng->txt('prg_deadline_period')
88  );
89  $grp3 = $input->group(
90  [
91  'deadline_date' => $input->dateTime(
92  $lng->txt('prg_deadline_date_label'),
93  $lng->txt('prg_deadline_date_desc')
94  )
95  ->withFormat($format)
96  ->withValue($this->getDeadlineDate() !== null ? $this->getDeadlineDate()->format('d.m.Y') : '')
97  ->withRequired(true)
98  ],
99  $lng->txt('prg_deadline_date')
100  );
101 
102  $sg = $input->switchableGroup(
103  [
104  'opt_no_deadline' => $grp1,
105  'opt_deadline_period' => $grp2,
106  'opt_deadline_date' => $grp3
107  ],
108  ''
109  );
110 
111  $deadline = "opt_no_deadline";
112  if (!is_null($this->getDeadlinePeriod()) && $this->getDeadlinePeriod() > 0) {
113  $deadline = 'opt_deadline_period';
114  }
115 
116  if (!is_null($this->getDeadlineDate())) {
117  $deadline = 'opt_deadline_date';
118  }
119 
120  return $input->section(
121  ['prg_deadline' => $sg->withValue($deadline)],
122  $lng->txt('prg_deadline_settings')
123  )
124  ->withAdditionalTransformation($refinery->custom()->transformation(
125  function ($vals) {
126  $period = null;
127  $date = null;
128 
129  if (isset($vals['prg_deadline'][1]['deadline_period'])) {
130  $period = (int) $vals['prg_deadline'][1]['deadline_period'];
131  }
132 
133  if (isset($vals['prg_deadline'][1]['deadline_date'])) {
134  $date = $vals['prg_deadline'][1]['deadline_date'];
135  }
136 
137  return new ilStudyProgrammeDeadlineSettings($period, $date);
138  }
139  ));
140  }
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...
$format
Definition: metadata.php:235
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
This describes inputs that can be used in forms.
Definition: FormInput.php:31
Refinery Factory $refinery
+ Here is the call graph for this function:

◆ withDeadlineDate()

ilStudyProgrammeDeadlineSettings::withDeadlineDate ( ?DateTimeImmutable  $deadline_date)

Definition at line 61 of file class.ilStudyProgrammeDeadlineSettings.php.

References $deadline_date.

62  {
63  $clone = clone $this;
64  $clone->deadline_date = $deadline_date;
65  return $clone;
66  }

◆ withDeadlinePeriod()

ilStudyProgrammeDeadlineSettings::withDeadlinePeriod ( ?int  $deadline_period)

Definition at line 45 of file class.ilStudyProgrammeDeadlineSettings.php.

References $deadline_period.

46  {
47  if (!is_null($deadline_period) && 0 > $deadline_period) {
48  throw new InvalidArgumentException('Numbers less than 0 are not allowed');
49  }
50 
51  $clone = clone $this;
52  $clone->deadline_period = $deadline_period;
53  return $clone;
54  }

Field Documentation

◆ $deadline_date

DateTimeImmutable ilStudyProgrammeDeadlineSettings::$deadline_date
protected

◆ $deadline_period

int ilStudyProgrammeDeadlineSettings::$deadline_period
protected

The documentation for this class was generated from the following file: