ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStudyProgrammeAssignment.php
Go to the documentation of this file.
1 <?php declare(strict_types = 1);
2 
3 /* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
14 {
16 
17  const DATE_TIME_FORMAT = 'Y-m-d H:i:s';
18  const DATE_FORMAT = 'Y-m-d';
19 
24 
28  protected $id;
29 
33  protected $usr_id;
34 
38  protected $root_prg_id;
39 
43  protected $last_change;
44 
48  protected $last_change_by;
49 
53  protected $restart_date;
54 
58  protected $restarted_asssignment_id = self::NO_RESTARTED_ASSIGNMENT;
59 
60 
61  public function __construct(int $id)
62  {
63  $this->id = $id;
64  }
65 
66  public function getId() : int
67  {
68  return $this->id;
69  }
70 
71  public function getRootId() : int
72  {
73  return $this->root_prg_id;
74  }
75 
77  {
78  $clone = clone $this;
79  $clone->root_prg_id = $root_prg_id;
80  return $clone;
81  }
82 
83  public function getUserId() : int
84  {
85  return $this->usr_id;
86  }
87 
89  {
90  $clone = clone $this;
91  $clone->usr_id = $usr_id;
92  return $clone;
93  }
94 
95  public function getLastChangeBy() : int
96  {
97  return $this->last_change_by;
98  }
99 
100  public function getLastChange() : ?DateTimeImmutable
101  {
102  if ($this->last_change) {
103  return DateTimeImmutable::createFromFormat(self::DATE_TIME_FORMAT, $this->last_change);
104  }
105  return $this->last_change;
106  }
107 
111  public function withLastChange(
112  int $last_change_by,
115  $new_date = $timestamp->format(self::DATE_TIME_FORMAT);
116  if ($this->getLastChange() && $this->getLastChange()->format(self::DATE_TIME_FORMAT) > $new_date) {
117  throw new ilException(
118  "Cannot set last change to an earlier date:"
119  . "\ncurrent: " . $this->getLastChange()->format(self::DATE_TIME_FORMAT)
120  . "\nnew: " . $new_date,
121  1
122  );
123  }
124  $clone = clone $this;
125  $clone->last_change = $new_date;
126  $clone->last_change_by = $last_change_by;
127  return $clone;
128  }
129 
130  public function getRestartDate() : ?DateTimeImmutable
131  {
132  return $this->restart_date;
133  }
134 
135  public function getRestartedAssignmentId() : int
136  {
138  }
139 
140  public function withRestarted(
144  $clone = clone $this;
145  $clone->restarted_asssignment_id = $restarted_asssignment_id;
146  $clone->restart_date = $restart_date;
147  return $clone;
148  }
149 }
withLastChange(int $last_change_by, DateTimeImmutable $timestamp)
Represents one assignment of the user to a program tree.
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
withRestarted(int $restarted_asssignment_id, DateTimeImmutable $restart_date=null)