Rapsys Git
/
airbundle
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Protect from infinite remove recursion
[airbundle]
/
Entity
/
Location.php
diff --git
a/Entity/Location.php
b/Entity/Location.php
index 6e66cea61a45df62a33d9731308a0a984fb0e492..613e46281c3664f841ddbc86f8790c8bfb50f966 100644
(file)
--- a/
Entity/Location.php
+++ b/
Entity/Location.php
@@
-31,7
+31,7
@@
class Location {
/**
* @var string
*/
/**
* @var string
*/
- pr
ivate $short
;
+ pr
otected $description
;
/**
* @var string
/**
* @var string
@@
-59,7
+59,12
@@
class Location {
private $longitude;
/**
private $longitude;
/**
- * @var boolean
+ * @var bool
+ */
+ private $indoor;
+
+ /**
+ * @var bool
*/
private $hotspot;
*/
private $hotspot;
@@
-92,6
+97,10
@@
class Location {
* Constructor
*/
public function __construct() {
* Constructor
*/
public function __construct() {
+ //Set defaults
+ $this->description = null;
+ $this->created = new \DateTime('now');
+ $this->updated = new \DateTime('now');
$this->sessions = new ArrayCollection();
$this->snippets = new ArrayCollection();
$this->users = new ArrayCollection();
$this->sessions = new ArrayCollection();
$this->snippets = new ArrayCollection();
$this->users = new ArrayCollection();
@@
-129,25
+138,25
@@
class Location {
}
/**
}
/**
- * Set
short
+ * Set
description
*
*
- * @param string $
short
+ * @param string $
description
*
* @return Location
*/
*
* @return Location
*/
- public function set
Short(string $short
): Location {
- $this->
short = $short
;
+ public function set
Description(?string $description
): Location {
+ $this->
description = $description
;
return $this;
}
/**
return $this;
}
/**
- * Get
short
+ * Get
description
*
* @return string
*/
*
* @return string
*/
- public function get
Short():
string {
- return $this->
short
;
+ public function get
Description(): ?
string {
+ return $this->
description
;
}
/**
}
/**
@@
-260,10
+269,32
@@
class Location {
return $this->longitude;
}
return $this->longitude;
}
+ /**
+ * Set indoor
+ *
+ * @param bool $indoor
+ *
+ * @return Session
+ */
+ public function setIndoor(bool $indoor): Location {
+ $this->indoor = $indoor;
+
+ return $this;
+ }
+
+ /**
+ * Get indoor
+ *
+ * @return bool
+ */
+ public function getIndoor(): bool {
+ return $this->indoor;
+ }
+
/**
* Set hotspot
*
/**
* Set hotspot
*
- * @param bool
ean
$hotspot
+ * @param bool $hotspot
*
* @return Session
*/
*
* @return Session
*/
@@
-276,7
+307,7
@@
class Location {
/**
* Get hotspot
*
/**
* Get hotspot
*
- * @return bool
ean
+ * @return bool
*/
public function getHotspot(): bool {
return $this->hotspot;
*/
public function getHotspot(): bool {
return $this->hotspot;
@@
-343,7
+374,7
@@
class Location {
* Remove session
*
* @param Session $session
* Remove session
*
* @param Session $session
- * @return bool
ean
+ * @return bool
*/
public function removeSession(Session $session): bool {
return $this->sessions->removeElement($session);
*/
public function removeSession(Session $session): bool {
return $this->sessions->removeElement($session);
@@
-375,7
+406,7
@@
class Location {
* Remove snippet
*
* @param Snippet $snippet
* Remove snippet
*
* @param Snippet $snippet
- * @return bool
ean
+ * @return bool
*/
public function removeSnippet(Snippet $snippet): bool {
return $this->snippets->removeElement($snippet);
*/
public function removeSnippet(Snippet $snippet): bool {
return $this->snippets->removeElement($snippet);
@@
-398,6
+429,9
@@
class Location {
* @return Location
*/
public function addUser(User $user): Location {
* @return Location
*/
public function addUser(User $user): Location {
+ //Add from owning side
+ $user->addSubscriber($this);
+
$this->users[] = $user;
return $this;
$this->users[] = $user;
return $this;
@@
-407,9
+441,16
@@
class Location {
* Remove user
*
* @param User $user
* Remove user
*
* @param User $user
- * @return bool
ean
+ * @return bool
*/
public function removeUser(User $user): bool {
*/
public function removeUser(User $user): bool {
+ if (!$this->users->contains($user)) {
+ return true;
+ }
+
+ //Remove from owning side
+ $user->removeSubscriber($this);
+
return $this->users->removeElement($user);
}
return $this->users->removeElement($user);
}