]> Raphaël G. Git Repositories - airbundle/blob - Entity/Slot.php
Update configureOptions and reverseTransform member function prototypes
[airbundle] / Entity / Slot.php
1 <?php declare(strict_types=1);
2
3 /*
4 * this file is part of the rapsys packbundle package.
5 *
6 * (c) raphaël gertz <symfony@rapsys.eu>
7 *
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\ArrayCollection;
15 use Doctrine\ORM\Event\PreUpdateEventArgs;
16
17 /**
18 * Slot
19 */
20 class Slot {
21 /**
22 * @var integer
23 */
24 private $id;
25
26 /**
27 * @var string
28 */
29 protected $title;
30
31 /**
32 * @var \DateTime
33 */
34 private $created;
35
36 /**
37 * @var \DateTime
38 */
39 private $updated;
40
41 /**
42 * @var ArrayCollection
43 */
44 private $sessions;
45
46 /**
47 * Constructor
48 */
49 public function __construct() {
50 //Set defaults
51 $this->created = new \DateTime('now');
52 $this->updated = new \DateTime('now');
53 $this->sessions = new ArrayCollection();
54 }
55
56 /**
57 * Get id
58 *
59 * @return integer
60 */
61 public function getId(): int {
62 return $this->id;
63 }
64
65 /**
66 * Set title
67 *
68 * @param string $title
69 *
70 * @return Title
71 */
72 public function setTitle(string $title) {
73 $this->title = $title;
74
75 return $this;
76 }
77
78 /**
79 * Get title
80 *
81 * @return string
82 */
83 public function getTitle(): string {
84 return $this->title;
85 }
86
87 /**
88 * Set created
89 *
90 * @param \DateTime $created
91 *
92 * @return Slot
93 */
94 public function setCreated(\DateTime $created) {
95 $this->created = $created;
96
97 return $this;
98 }
99
100 /**
101 * Get created
102 *
103 * @return \DateTime
104 */
105 public function getCreated(): \DateTime {
106 return $this->created;
107 }
108
109 /**
110 * Set updated
111 *
112 * @param \DateTime $updated
113 *
114 * @return Slot
115 */
116 public function setUpdated(\DateTime $updated) {
117 $this->updated = $updated;
118
119 return $this;
120 }
121
122 /**
123 * Get updated
124 *
125 * @return \DateTime
126 */
127 public function getUpdated(): \DateTime {
128 return $this->updated;
129 }
130
131 /**
132 * Add session
133 *
134 * @param Session $session
135 *
136 * @return Slot
137 */
138 public function addSession(Session $session): Slot {
139 $this->sessions[] = $session;
140
141 return $this;
142 }
143
144 /**
145 * Remove session
146 *
147 * @param Session $session
148 */
149 public function removeSession(Session $session): bool {
150 return $this->sessions->removeElement($session);
151 }
152
153 /**
154 * Get sessions
155 *
156 * @return ArrayCollection
157 */
158 public function getSessions(): ArrayCollection {
159 return $this->sessions;
160 }
161
162 /**
163 * {@inheritdoc}
164 */
165 public function preUpdate(PreUpdateEventArgs $eventArgs) {
166 //Check that we have a slot instance
167 if (($slot = $eventArgs->getEntity()) instanceof Slot) {
168 //Set updated value
169 $slot->setUpdated(new \DateTime('now'));
170 }
171 }
172
173 /**
174 * Returns a string representation of the slot
175 *
176 * @return string
177 */
178 public function __toString(): string {
179 return $this->title;
180 }
181 }