Entity/Choice.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 Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* Choice
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="Abienvenu\KyelaBundle\Entity\ChoiceRepository")
*/
class Choice extends Entity
{
public function __toString()
{
return $this->name;
}
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=64)
* @Assert\NotBlank()
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="value", type="integer")
*/
private $value;
/**
* @var string
*
* @ORM\Column(name="color", type="string", length=16)
*/
private $color;
/**
* @var string
*
* @ORM\Column(name="icon", type="string", length=16, nullable=true)
*/
private $icon;
/**
* @var integer
*
* @ORM\Column(name="priority", type="integer")
*/
private $priority;
/**
* @ORM\OneToMany(targetEntity="Participation", mappedBy="choice", cascade={"remove"})
*/
private $participations;
/**
* @ORM\ManyToOne(targetEntity="Poll", inversedBy="choices")
*/
private $poll;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Choice
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set value
*
* @param integer $value
* @return Choice
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* Get value
*
* @return integer
*/
public function getValue()
{
return $this->value;
}
/**
* Set color
*
* @param string $color
* @return Choice
*/
public function setColor($color)
{
$this->color = $color;
return $this;
}
/**
* Get color
*
* @return string
*/
public function getColor()
{
return $this->color;
}
/**
* Constructor
*/
public function __construct()
{
$this->participations = new ArrayCollection();
}
/**
* Add participations
*
* @param Participation $participations
* @return Choice
*/
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 Choice
*/
public function setPoll(Poll $poll = null)
{
$this->poll = $poll;
return $this;
}
/**
* Get poll
*
* @return Poll
*/
public function getPoll()
{
return $this->poll;
}
/**
* Set priority
*
* @param integer $priority
* @return Choice
*/
public function setPriority($priority)
{
$this->priority = $priority;
return $this;
}
/**
* Get priority
*
* @return integer
*/
public function getPriority()
{
return $this->priority;
}
/**
* Set icon
*
* @param string $icon
* @return Choice
*/
public function setIcon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* Get icon
*
* @return string
*/
public function getIcon()
{
return $this->icon;
}
}