X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airbundle/blobdiff_plain/60e532d5368faa6cbb048d61cac5695c0b972782..aa392e7390d8c6abd217d09b8a646f41625a91c7:/Entity/Location.php

diff --git a/Entity/Location.php b/Entity/Location.php
index 613e462..75f6f45 100644
--- a/Entity/Location.php
+++ b/Entity/Location.php
@@ -1,16 +1,17 @@
 <?php declare(strict_types=1);
 
 /*
- * this file is part of the rapsys packbundle package.
+ * This file is part of the Rapsys AirBundle package.
  *
- * (c) raphaël gertz <symfony@rapsys.eu>
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
  *
- * for the full copyright and license information, please view the license
+ * 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\Collection;
 use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\ORM\Event\PreUpdateEventArgs;
 
@@ -19,9 +20,9 @@ use Doctrine\ORM\Event\PreUpdateEventArgs;
  */
 class Location {
 	/**
-	 * @var integer
+	 * Primary key
 	 */
-	private $id;
+	private ?int $id = null;
 
 	/**
 	 * @var string
@@ -31,7 +32,7 @@ class Location {
 	/**
 	 * @var string
 	 */
-	protected $description;
+	private ?string $description = null;
 
 	/**
 	 * @var string
@@ -69,38 +70,39 @@ class Location {
 	private $hotspot;
 
 	/**
-	 * @var \DateTime
+	 * Create datetime
 	 */
-	private $created;
+	private \DateTime $created;
 
 	/**
-	 * @var \DateTime
+	 * Update datetime
 	 */
-	private $updated;
+	private \DateTime $updated;
 
 	/**
-	 * @var ArrayCollection
+	 * Sessions collection
 	 */
-	private $sessions;
+	private Collection $sessions;
 
 	/**
-	 * @var ArrayCollection
+	 * Snippets collection
 	 */
-	private $snippets;
+	private Collection $snippets;
 
 	/**
-	 * @var ArrayCollection
+	 * Users collection
 	 */
-	private $users;
+	private Collection $users;
 
 	/**
 	 * Constructor
 	 */
 	public function __construct() {
 		//Set defaults
-		$this->description = null;
 		$this->created = new \DateTime('now');
 		$this->updated = new \DateTime('now');
+
+		//Set collections
 		$this->sessions = new ArrayCollection();
 		$this->snippets = new ArrayCollection();
 		$this->users = new ArrayCollection();
@@ -111,7 +113,7 @@ class Location {
 	 *
 	 * @return integer
 	 */
-	public function getId(): int {
+	public function getId(): ?int {
 		return $this->id;
 	}
 
@@ -430,7 +432,7 @@ class Location {
 	 */
 	public function addUser(User $user): Location {
 		//Add from owning side
-		$user->addSubscriber($this);
+		$user->addLocation($this);
 
 		$this->users[] = $user;
 
@@ -444,12 +446,12 @@ class Location {
 	 * @return bool
 	 */
 	public function removeUser(User $user): bool {
-		if (!$this->users->contains($user)) {
+		if (!$this->locations->contains($user)) {
 			return true;
 		}
 
 		//Remove from owning side
-		$user->removeSubscriber($this);
+		$user->removeLocation($this);
 
 		return $this->users->removeElement($user);
 	}
@@ -468,7 +470,7 @@ class Location {
 	 */
 	public function preUpdate(PreUpdateEventArgs $eventArgs) {
 		//Check that we have a location instance
-		if (($location = $eventArgs->getEntity()) instanceof Location) {
+		if (($location = $eventArgs->getObject()) instanceof Location) {
 			//Set updated value
 			$location->setUpdated(new \DateTime('now'));
 		}