Rapsys Git
/
airbundle
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add missing translation
[airbundle]
/
Entity
/
Dance.php
diff --git
a/Entity/Dance.php
b/Entity/Dance.php
index e3779da83fc03d8558dbaa0c4dead87b3aea33a8..6ae5f1bb14dcd72bd7e7e47b4a3f94ba44cc3887 100644
(file)
--- a/
Entity/Dance.php
+++ b/
Entity/Dance.php
@@
-1,16
+1,17
@@
<?php declare(strict_types=1);
/*
<?php declare(strict_types=1);
/*
- *
this file is part of the rapsys packb
undle package.
+ *
This file is part of the Rapsys AirB
undle package.
*
*
- * (c)
raphaël g
ertz <symfony@rapsys.eu>
+ * (c)
Raphaël G
ertz <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;
* 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;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Event\PreUpdateEventArgs;
@@
-19,42
+20,42
@@
use Doctrine\ORM\Event\PreUpdateEventArgs;
*/
class Dance {
/**
*/
class Dance {
/**
- *
@var integer
+ *
Primary key
*/
*/
- private
$id
;
+ private
?int $id = null
;
/**
/**
- *
@var string
+ *
Create datetime
*/
*/
- pr
otected $title
;
+ pr
ivate \DateTime $created
;
/**
/**
- *
@var \DateT
ime
+ *
Update datet
ime
*/
*/
- private
$cre
ated;
+ private
\DateTime $upd
ated;
/**
/**
- *
@var \DateTime
+ *
Applications collection
*/
*/
- private
$updated
;
+ private
Collection $applications
;
/**
/**
- *
@var ArrayC
ollection
+ *
Users c
ollection
*/
*/
- private $applications;
-
- /**
- * @var ArrayCollection
- */
- private $users;
+ private Collection $users;
/**
* Constructor
/**
* Constructor
+ *
+ * @param string $name The dance name
+ * @param string $type The dance type
*/
*/
- public function __construct() {
+ public function __construct(
private string $name, private string $type
) {
//Set defaults
$this->created = new \DateTime('now');
$this->updated = new \DateTime('now');
//Set defaults
$this->created = new \DateTime('now');
$this->updated = new \DateTime('now');
+
+ //Set collections
$this->applications = new ArrayCollection();
$this->users = new ArrayCollection();
}
$this->applications = new ArrayCollection();
$this->users = new ArrayCollection();
}
@@
-64,30
+65,52
@@
class Dance {
*
* @return integer
*/
*
* @return integer
*/
- public function getId(): int {
+ public function getId():
?
int {
return $this->id;
}
/**
return $this->id;
}
/**
- * Set title
+ * Set name
+ *
+ * @param string $name
+ *
+ * @return Dance
+ */
+ public function setName(string $name): Dance {
+ $this->name = $name;
+
+ return $this;
+ }
+
+ /**
+ * Get name
+ *
+ * @return string
+ */
+ public function getName(): string {
+ return $this->name;
+ }
+
+ /**
+ * Set type
*
*
- * @param string $t
itl
e
+ * @param string $t
yp
e
*
* @return Dance
*/
*
* @return Dance
*/
- public function setT
itle(string $titl
e): Dance {
- $this->t
itle = $titl
e;
+ public function setT
ype(string $typ
e): Dance {
+ $this->t
ype = $typ
e;
return $this;
}
/**
return $this;
}
/**
- * Get t
itl
e
+ * Get t
yp
e
*
* @return string
*/
*
* @return string
*/
- public function getT
itl
e(): string {
- return $this->t
itl
e;
+ public function getT
yp
e(): string {
+ return $this->t
yp
e;
}
/**
}
/**
@@
-175,6
+198,9
@@
class Dance {
* @return Dance
*/
public function addUser(User $user): Dance {
* @return Dance
*/
public function addUser(User $user): Dance {
+ //Add from owning side
+ $user->addDance($this);
+
$this->users[] = $user;
return $this;
$this->users[] = $user;
return $this;
@@
-188,6
+214,13
@@
class Dance {
* @return bool
*/
public function removeUser(User $user): bool {
* @return bool
*/
public function removeUser(User $user): bool {
+ if (!$this->dances->contains($user)) {
+ return true;
+ }
+
+ //Remove from owning side
+ $user->removeDance($this);
+
return $this->users->removeElement($user);
}
return $this->users->removeElement($user);
}
@@
-204,8
+237,8
@@
class Dance {
* {@inheritdoc}
*/
public function preUpdate(PreUpdateEventArgs $eventArgs) {
* {@inheritdoc}
*/
public function preUpdate(PreUpdateEventArgs $eventArgs) {
- //Check that we have a
n session
instance
- if (($dance = $eventArgs->get
Entity
()) instanceof Dance) {
+ //Check that we have a
dance
instance
+ if (($dance = $eventArgs->get
Object
()) instanceof Dance) {
//Set updated value
$dance->setUpdated(new \DateTime('now'));
}
//Set updated value
$dance->setUpdated(new \DateTime('now'));
}
@@
-217,6
+250,6
@@
class Dance {
* @return string
*/
public function __toString(): string {
* @return string
*/
public function __toString(): string {
- return $this->
title
;
+ return $this->
name.' '.lcfirst($this->type)
;
}
}
}
}