Entity/Participant.php
<?php
/*
* Copyright 2014-2016 Arnaud Bienvenu
*
* This file is part of Kyela.
* Kyela 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.
* Kyela 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 Kyela. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace Abienvenu\KyelaBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @ORM\Entity
* @ORM\Table(name="Participant")
*/
class Participant extends Entity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", length=100)
* @Assert\NotBlank()
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="priority", type="integer")
*/
private $priority = 0;
/**
* @ORM\OneToMany(targetEntity="Participation", mappedBy="participant", cascade={"remove"})
*/
private $participations;
/**
* @ORM\ManyToOne(targetEntity="Poll", inversedBy="participants")
*/
private $poll;
public function __construct()
{
$this->participations = new ArrayCollection();
}
/**
* @return string
*/
public function __toString()
{
return $this->name;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Participant
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @return mixed
*/
public function getPriority()
{
return $this->priority;
}
/**
* @param mixed $priority
*/
public function setPriority($priority)
{
$this->priority = $priority;
}
/**
* Add participations
*
* @param \Abienvenu\KyelaBundle\Entity\Participation $participations
* @return Participant
*/
public function addParticipation(Participation $participations)
{
$this->participations[] = $participations;
return $this;
}
/**
* Remove participations
*
* @param Participation $participations
*/
public function removeParticipation(Participation $participations)
{
$this->participations->removeElement($participations);
}
/**
* Get participations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getParticipations()
{
return $this->participations;
}
/**
* Set poll
*
* @param Poll $poll
* @return Participant
*/
public function setPoll(Poll $poll = null)
{
$this->poll = $poll;
return $this;
}
/**
* Get poll
*
* @return Poll
*/
public function getPoll()
{
return $this->poll;
}
}