ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeDeadlineSettings Class Reference
+ Collaboration diagram for ilStudyProgrammeDeadlineSettings:

Public Member Functions

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

Protected Attributes

 $deadline_period
 
 $deadline_date
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $deadline_date, and $deadline_period.

24  {
25  if (!is_null($deadline_period) && 0 > $deadline_period) {
26  throw new InvalidArgumentException(
27  'Numbers less than 0 are not allowed'
28  );
29  }
30 
31  $this->deadline_period = $deadline_period;
32  $this->deadline_date = $deadline_date;
33  }

Member Function Documentation

◆ getDeadlineDate()

ilStudyProgrammeDeadlineSettings::getDeadlineDate ( )

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

References $deadline_date.

Referenced by toFormInput().

+ Here is the caller graph for this function:

◆ getDeadlinePeriod()

ilStudyProgrammeDeadlineSettings::getDeadlinePeriod ( )

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

References $deadline_period.

Referenced by toFormInput().

+ Here is the caller graph for this function:

◆ toFormInput()

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

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

References $format, ILIAS\Data\Factory\dateFormat(), getDeadlineDate(), getDeadlinePeriod(), and ilLanguage\txt().

70  : Field\Input {
71  $format = $data_factory->dateFormat()->germanShort();
72 
73  $grp1 = $input->group([], $lng->txt('prg_no_deadline'));
74  $grp2 = $input->group(
75  [
76  'deadline_period' => $input->numeric(
77  '',
78  $lng->txt('prg_deadline_period_desc')
79  )
80  ->withAdditionalTransformation($refinery->int()->isGreaterThan(-1))
81  ->withValue($this->getDeadlinePeriod() !== null ? $this->getDeadlinePeriod() : null)
82  ],
83  $lng->txt('prg_deadline_period')
84  );
85  $grp3 = $input->group(
86  [
87  'deadline_date' => $input->dateTime(
88  '',
89  $lng->txt('prg_deadline_date_desc')
90  )
91  ->withFormat($format)
92  ->withValue($this->getDeadlineDate() !== null ? $this->getDeadlineDate()->format('d.m.Y') : '')
93  ->withRequired(true)
94  ],
95  $lng->txt('prg_deadline_date')
96  );
97 
98  $sg = $input->switchableGroup(
99  [
100  'opt_no_deadline' => $grp1,
101  'opt_deadline_period' => $grp2,
102  'opt_deadline_date' => $grp3
103  ],
104  ''
105  );
106 
107  $deadline = "opt_no_deadline";
108  if (!is_null($this->getDeadlinePeriod()) && $this->getDeadlinePeriod() > 0) {
109  $deadline = 'opt_deadline_period';
110  }
111 
112  if (!is_null($this->getDeadlineDate())) {
113  $deadline = 'opt_deadline_date';
114  }
115 
116  return $input->section(
117  ['prg_deadline' => $sg->withValue($deadline)],
118  $lng->txt('prg_deadline_settings')
119  )
120  ->withAdditionalTransformation($refinery->custom()->transformation(
121  function ($vals) {
122  $period = null;
123  $date = null;
124 
125  if (isset($vals['prg_deadline'][1]['deadline_period'])) {
126  $period = (int) $vals['prg_deadline'][1]['deadline_period'];
127  }
128 
129  if (isset($vals['prg_deadline'][1]['deadline_date'])) {
130  $date = new DateTime($vals['prg_deadline'][1]['deadline_date']);
131  }
132 
133  return new ilStudyProgrammeDeadlineSettings($period, $date);
134  }
135  ));
136  }
$lng
$format
Definition: metadata.php:218
This describes the datetime-field.
Definition: DateTime.php:13
+ Here is the call graph for this function:

◆ withDeadlineDate()

ilStudyProgrammeDeadlineSettings::withDeadlineDate ( ?DateTime  $deadline_date)

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

References $deadline_date.

◆ withDeadlinePeriod()

ilStudyProgrammeDeadlineSettings::withDeadlinePeriod ( ?int  $deadline_period)

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

References $deadline_period.

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

Field Documentation

◆ $deadline_date

ilStudyProgrammeDeadlineSettings::$deadline_date
protected

◆ $deadline_period

ilStudyProgrammeDeadlineSettings::$deadline_period
protected

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