api.emotionhero.com/src/Models/Level.php
2016-09-04 12:06:02 +01:00

96 lines
1.7 KiB
PHP

<?php
namespace EmotionHero\Models;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as JMS;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Users
*
* @ORM\Table(name="levels")
* @ORM\Entity
*/
class Level
{
/**
* @var integer
*
* @ORM\Column(name="id",type="integer")
* @ORM\Id
* @ORM\GeneratedValue
*/
private $id;
/**
* Name of the level
* @var string
* @ORM\Column
*/
private $name;
/**
* @ORM\OneToMany(targetEntity="Target", mappedBy="level", cascade={"persist"})
* @ORM\OrderBy({"position" = "ASC"})
*/
private $targets;
/**
* @JMS\Exclude
* @ORM\OneToMany(targetEntity="Game", mappedBy="level", fetch="EXTRA_LAZY")
*/
private $games;
public function __construct()
{
$this->targets = new ArrayCollection();
$this->games = new ArrayCollection();
}
public function createTarget(Emotion $emotion, float $score, float $time) {
$pos = $this->targets->count()+1;
$target = new Target($this, $pos, $emotion, $score, $time);
$this->targets->set($pos, $target);
}
/**
* Sets the value of id.
*
* @param integer $id the id
*
* @return self
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Sets the Name of the level.
*
* @param string $name the name
*
* @return self
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Gets the value of id.
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}