mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
278 lines
4.9 KiB
PHP
278 lines
4.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/*
|
|
* Chill is a software for social workers
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Chill\EventBundle\Entity;
|
|
|
|
use ArrayIterator;
|
|
use Chill\MainBundle\Entity\Center;
|
|
use Chill\MainBundle\Entity\HasCenterInterface;
|
|
use Chill\MainBundle\Entity\HasScopeInterface;
|
|
use Chill\MainBundle\Entity\Scope;
|
|
use Chill\MainBundle\Entity\User;
|
|
use DateTime;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Traversable;
|
|
|
|
/**
|
|
* Class Event.
|
|
*
|
|
* @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository")
|
|
* @ORM\Table(name="chill_event_event")
|
|
* @ORM\HasLifecycleCallbacks
|
|
*/
|
|
class Event implements HasCenterInterface, HasScopeInterface
|
|
{
|
|
/**
|
|
* @var Center
|
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
|
|
*/
|
|
private $center;
|
|
|
|
/**
|
|
* @var Scope
|
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
|
*/
|
|
private $circle;
|
|
|
|
/**
|
|
* @var DateTime
|
|
* @ORM\Column(type="datetime")
|
|
*/
|
|
private $date;
|
|
|
|
/**
|
|
* @var int
|
|
*
|
|
* @ORM\Id
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @var User
|
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
|
|
*/
|
|
private $moderator;
|
|
|
|
/**
|
|
* @var string
|
|
* @ORM\Column(type="string", length=150)
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @var Participation
|
|
* @ORM\OneToMany(
|
|
* targetEntity="Chill\EventBundle\Entity\Participation",
|
|
* mappedBy="event")
|
|
*/
|
|
private $participations;
|
|
|
|
/**
|
|
* @var EventType
|
|
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType")
|
|
*/
|
|
private $type;
|
|
|
|
/**
|
|
* Event constructor.
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->participations = new ArrayCollection();
|
|
}
|
|
|
|
/**
|
|
* Add participation.
|
|
*
|
|
* @return Event
|
|
*/
|
|
public function addParticipation(Participation $participation)
|
|
{
|
|
$this->participations[] = $participation;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Center
|
|
*/
|
|
public function getCenter()
|
|
{
|
|
return $this->center;
|
|
}
|
|
|
|
/**
|
|
* @return Scope
|
|
*/
|
|
public function getCircle()
|
|
{
|
|
return $this->circle;
|
|
}
|
|
|
|
/**
|
|
* Get date.
|
|
*
|
|
* @return DateTime
|
|
*/
|
|
public function getDate()
|
|
{
|
|
return $this->date;
|
|
}
|
|
|
|
/**
|
|
* Get id.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function getId()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
/**
|
|
* @return int
|
|
*/
|
|
public function getModerator()
|
|
{
|
|
return $this->moderator;
|
|
}
|
|
|
|
/**
|
|
* Get label.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
/**
|
|
* @return ArrayIterator|Collection|Traversable
|
|
*/
|
|
public function getParticipations()
|
|
{
|
|
return $this->getParticipationsOrdered();
|
|
}
|
|
|
|
/**
|
|
* Sort Collection of Participations.
|
|
*
|
|
* @return ArrayIterator|Traversable
|
|
*/
|
|
public function getParticipationsOrdered()
|
|
{
|
|
$iterator = $this->participations->getIterator();
|
|
|
|
$iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()));
|
|
|
|
return $iterator;
|
|
}
|
|
|
|
/**
|
|
* @deprecated
|
|
*
|
|
* @return Scope
|
|
*/
|
|
public function getScope()
|
|
{
|
|
return $this->getCircle();
|
|
}
|
|
|
|
/**
|
|
* @return EventType
|
|
*/
|
|
public function getType()
|
|
{
|
|
return $this->type;
|
|
}
|
|
|
|
/**
|
|
* Remove participation.
|
|
*/
|
|
public function removeParticipation(Participation $participation)
|
|
{
|
|
$this->participations->removeElement($participation);
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function setCenter(Center $center)
|
|
{
|
|
$this->center = $center;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function setCircle(Scope $circle)
|
|
{
|
|
$this->circle = $circle;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set date.
|
|
*
|
|
* @return Event
|
|
*/
|
|
public function setDate(DateTime $date)
|
|
{
|
|
$this->date = $date;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @param int $moderator
|
|
*
|
|
* @return Event
|
|
*/
|
|
public function setModerator($moderator)
|
|
{
|
|
$this->moderator = $moderator;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Set label.
|
|
*
|
|
* @param string $label
|
|
*
|
|
* @return Event
|
|
*/
|
|
public function setName($label)
|
|
{
|
|
$this->name = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function setType(EventType $type)
|
|
{
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
}
|
|
}
|