* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ namespace Chill\EventBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Scope; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Chill\MainBundle\Entity\HasCenterInterface; use Chill\MainBundle\Entity\HasScopeInterface; /** * Class Event * * @package Chill\EventBundle\Entity * @ORM\Entity(repositoryClass="Chill\EventBundle\Repository\EventRepository") * @ORM\Table(name="chill_event_event") * @ORM\HasLifecycleCallbacks() */ class Event implements HasCenterInterface, HasScopeInterface { /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * @ORM\Column(type="string", length=150) */ private $name; /** * @var \DateTime * @ORM\Column(type="datetime") */ private $date; /** * * @var Center * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center") */ private $center; /** * * @var EventType * @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType") */ private $type; /** * * @var Scope * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope") */ private $circle; /** * @var Participation * @ORM\OneToMany( * targetEntity="Chill\EventBundle\Entity\Participation", * mappedBy="event") */ private $participations; /** * * @var User * @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User") */ private $moderator; /** * Event constructor. */ public function __construct() { $this->participations = new ArrayCollection(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set label * * @param string $label * @return Event */ public function setName($label) { $this->name = $label; return $this; } /** * Get label * * @return string */ public function getName() { return $this->name; } /** * Set date * * @param \DateTime $date * @return Event */ public function setDate(\DateTime $date) { $this->date = $date; return $this; } /** * Get date * * @return \DateTime */ public function getDate() { return $this->date; } /** * @param Center $center * @return $this */ public function setCenter(Center $center) { $this->center = $center; return $this; } /** * @return EventType */ public function getType() { return $this->type; } /** * @param EventType $type * @return $this */ public function setType(EventType $type) { $this->type = $type; return $this; } /** * @return Center */ public function getCenter() { return $this->center; } /** * @return Scope */ public function getCircle() { return $this->circle; } /** * @param Scope $circle * @return $this */ public function setCircle(\Chill\MainBundle\Entity\Scope $circle) { $this->circle = $circle; return $this; } /** * @deprecated * @return Scope */ public function getScope() { return $this->getCircle(); } /** * Add participation * * @param Participation $participation * @return Event */ public function addParticipation(Participation $participation) { $this->participations[] = $participation; return $this; } /** * Remove participation * * @param Participation $participation */ public function removeParticipation(Participation $participation) { $this->participations->removeElement($participation); } /** * @return \ArrayIterator|\Traversable|Collection */ public function getParticipations() { return $this->getParticipationsOrdered(); } /** * Sort Collection of Participations * * @return \ArrayIterator|\Traversable */ public function getParticipationsOrdered() { $iterator = $this->participations->getIterator(); $iterator->uasort(function($first, $second) { return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()); }); return $iterator; } /** * @return int */ public function getModerator() { return $this->moderator; } /** * @param int $moderator * @return Event */ public function setModerator($moderator) { $this->moderator = $moderator; return $this; } }