From 40fa570f0ce4fc6b518ab7b6d71fde5bf249cd56 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Rapha=C3=ABl=20Gertz?= <git@rapsys.eu>
Date: Sat, 28 Aug 2021 05:49:09 +0200
Subject: [PATCH] Add dance entity

---
 Entity/Dance.php | 219 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 219 insertions(+)
 create mode 100644 Entity/Dance.php

diff --git a/Entity/Dance.php b/Entity/Dance.php
new file mode 100644
index 0000000..fa07ba9
--- /dev/null
+++ b/Entity/Dance.php
@@ -0,0 +1,219 @@
+<?php declare(strict_types=1);
+
+/*
+ * this file is part of the rapsys packbundle package.
+ *
+ * (c) raphaël gertz <symfony@rapsys.eu>
+ *
+ * for the full copyright and license information, please view the license
+ * file that was distributed with this source code.
+ */
+
+namespace Rapsys\AirBundle\Entity;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
+/**
+ * Dance
+ */
+class Dance {
+	/**
+	 * @var integer
+	 */
+	private $id;
+
+	/**
+	 * @var string
+	 */
+	protected $title;
+
+	/**
+	 * @var \DateTime
+	 */
+	private $created;
+
+	/**
+	 * @var \DateTime
+	 */
+	private $updated;
+
+	/**
+	 * @var ArrayCollection
+	 */
+	private $applications;
+
+	/**
+	 * @var ArrayCollection
+	 */
+	private $users;
+
+	/**
+	 * Constructor
+	 */
+	public function __construct() {
+		$this->applications = new ArrayCollection();
+		$this->users = new ArrayCollection();
+	}
+
+	/**
+	 * Get id
+	 *
+	 * @return integer
+	 */
+	public function getId(): int {
+		return $this->id;
+	}
+
+	/**
+	 * Set title
+	 *
+	 * @param string $title
+	 *
+	 * @return Dance
+	 */
+	public function setTitle(string $title): Dance {
+		$this->title = $title;
+
+		return $this;
+	}
+
+	/**
+	 * Get title
+	 *
+	 * @return string
+	 */
+	public function getTitle(): string {
+		return $this->title;
+	}
+
+	/**
+	 * Set created
+	 *
+	 * @param \DateTime $created
+	 *
+	 * @return Dance
+	 */
+	public function setCreated(\DateTime $created): Dance {
+		$this->created = $created;
+
+		return $this;
+	}
+
+	/**
+	 * Get created
+	 *
+	 * @return \DateTime
+	 */
+	public function getCreated(): \DateTime {
+		return $this->created;
+	}
+
+	/**
+	 * Set updated
+	 *
+	 * @param \DateTime $updated
+	 *
+	 * @return Dance
+	 */
+	public function setUpdated(\DateTime $updated): Dance {
+		$this->updated = $updated;
+
+		return $this;
+	}
+
+	/**
+	 * Get updated
+	 *
+	 * @return \DateTime
+	 */
+	public function getUpdated(): \DateTime {
+		return $this->updated;
+	}
+
+	/**
+	 * Add application
+	 *
+	 * @param Application $application
+	 *
+	 * @return Dance
+	 */
+	public function addApplication(Application $application): Dance {
+		$this->applications[] = $application;
+
+		return $this;
+	}
+
+	/**
+	 * Remove application
+	 *
+	 * @param Application $application
+	 *
+	 * @return bool
+	 */
+	public function removeApplication(Application $application): bool {
+		return $this->applications->removeElement($application);
+	}
+
+	/**
+	 * Get applications
+	 *
+	 * @return ArrayCollection
+	 */
+	public function getApplications(): ArrayCollection {
+		return $this->applications;
+	}
+
+	/**
+	 * Add user
+	 *
+	 * @param User $user
+	 *
+	 * @return Dance
+	 */
+	public function addUser(User $user): Dance {
+		$this->users[] = $user;
+
+		return $this;
+	}
+
+	/**
+	 * Remove user
+	 *
+	 * @param User $user
+	 *
+	 * @return bool
+	 */
+	public function removeUser(User $user): bool {
+		return $this->users->removeElement($user);
+	}
+
+	/**
+	 * Get users
+	 *
+	 * @return ArrayCollection
+	 */
+	public function getUsers(): ArrayCollection {
+		return $this->users;
+	}
+
+	/**
+	 * {@inheritdoc}
+	 */
+	public function preUpdate(PreUpdateEventArgs $eventArgs) {
+		//Check that we have an session instance
+		if (($dance = $eventArgs->getEntity()) instanceof Dance) {
+			//Set updated value
+			$dance->setUpdated(new \DateTime('now'));
+		}
+	}
+
+	/**
+	 * Returns a string representation of the slot
+	 *
+	 * @return string
+	 */
+	public function __toString(): string {
+		return $this->title;
+	}
+}
-- 
2.41.1