1 <?php
declare(strict_types
=1);
4 * this file is part of the rapsys packbundle package.
6 * (c) raphaël gertz <symfony@rapsys.eu>
8 * for the full copyright and license information, please view the license
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Entity
;
14 use Doctrine\Common\Collections\ArrayCollection
;
15 use Doctrine\ORM\Event\PreUpdateEventArgs
;
47 * @var ArrayCollection
49 private $applications;
52 * @var ArrayCollection
59 * @param string $name The dance name
60 * @param string $type The dance type
62 public function __construct(string $name, string $type) {
66 $this->created
= new \
DateTime('now');
67 $this->updated
= new \
DateTime('now');
70 $this->applications
= new ArrayCollection();
71 $this->users
= new ArrayCollection();
79 public function getId(): int {
90 public function setName(string $name): Dance
{
101 public function getName(): string {
108 * @param string $type
112 public function setType(string $type): Dance
{
123 public function getType(): string {
130 * @param \DateTime $created
134 public function setCreated(\DateTime
$created): Dance
{
135 $this->created
= $created;
145 public function getCreated(): \DateTime
{
146 return $this->created
;
152 * @param \DateTime $updated
156 public function setUpdated(\DateTime
$updated): Dance
{
157 $this->updated
= $updated;
167 public function getUpdated(): \DateTime
{
168 return $this->updated
;
174 * @param Application $application
178 public function addApplication(Application
$application): Dance
{
179 $this->applications
[] = $application;
187 * @param Application $application
191 public function removeApplication(Application
$application): bool {
192 return $this->applications
->removeElement($application);
198 * @return ArrayCollection
200 public function getApplications(): ArrayCollection
{
201 return $this->applications
;
211 public function addUser(User
$user): Dance
{
212 //Add from owning side
213 $user->addSubscriber($this);
215 $this->users
[] = $user;
227 public function removeUser(User
$user): bool {
228 if (!$this->users
->contains($user)) {
232 //Remove from owning side
233 $user->removeSubscriber($this);
235 return $this->users
->removeElement($user);
241 * @return ArrayCollection
243 public function getUsers(): ArrayCollection
{
250 public function preUpdate(PreUpdateEventArgs
$eventArgs) {
251 //Check that we have a dance instance
252 if (($dance = $eventArgs->getEntity()) instanceof Dance
) {
254 $dance->setUpdated(new \
DateTime('now'));
259 * Returns a string representation of the slot
263 public function __toString(): string {
264 return $this->name
.' '.lcfirst($this->type
);