mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 02:53:50 +00:00
Clean database, to avoid double participations on event
This commit is contained in:
@@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
@@ -30,7 +31,9 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
* @ORM\Entity(
|
||||
* repositoryClass="Chill\EventBundle\Repository\ParticipationRepository")
|
||||
*
|
||||
* @ORM\Table(name="chill_event_participation")
|
||||
* @ORM\Table(name="chill_event_participation", uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="chill_event_participation_event_person_unique_idx", columns={"event_id", "person_id"})
|
||||
* })
|
||||
*
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
@@ -55,30 +58,28 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
private ?int $id = null;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime")
|
||||
*/
|
||||
private ?\DateTime $lastUpdate = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\Person")
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private ?Person $person = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role")
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private ?Role $role = null;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Status")
|
||||
* @Assert\NotNull()
|
||||
*/
|
||||
private ?Status $status = null;
|
||||
|
||||
/**
|
||||
* @return Center
|
||||
*/
|
||||
public function getCenter()
|
||||
public function getCenter(): null|Center
|
||||
{
|
||||
if (null === $this->getEvent()) {
|
||||
throw new \RuntimeException('The event is not linked with this instance. You should initialize the event with a valid center before.');
|
||||
@@ -100,7 +101,7 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
@@ -112,7 +113,7 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
public function getLastUpdate()
|
||||
{
|
||||
return $this->lastUpdate;
|
||||
return $this->getUpdatedAt();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,10 +243,6 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
public function setEvent(?Event $event = null)
|
||||
{
|
||||
if ($this->event !== $event) {
|
||||
$this->update();
|
||||
}
|
||||
|
||||
$this->event = $event;
|
||||
|
||||
return $this;
|
||||
@@ -258,10 +255,6 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
public function setPerson(?Person $person = null)
|
||||
{
|
||||
if ($person !== $this->person) {
|
||||
$this->update();
|
||||
}
|
||||
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
@@ -274,9 +267,6 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
public function setRole(?Role $role = null)
|
||||
{
|
||||
if ($role !== $this->role) {
|
||||
$this->update();
|
||||
}
|
||||
$this->role = $role;
|
||||
|
||||
return $this;
|
||||
@@ -289,10 +279,6 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
*/
|
||||
public function setStatus(?Status $status = null)
|
||||
{
|
||||
if ($this->status !== $status) {
|
||||
$this->update();
|
||||
}
|
||||
|
||||
$this->status = $status;
|
||||
|
||||
return $this;
|
||||
@@ -302,11 +288,10 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
||||
* Set lastUpdate.
|
||||
*
|
||||
* @return Participation
|
||||
* @deprecated
|
||||
*/
|
||||
protected function update()
|
||||
{
|
||||
$this->lastUpdate = new \DateTime('now');
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user