api.emotionhero.com/src/Models/Level.php

95 lines
1.6 KiB
PHP
Raw Normal View History

2016-09-01 10:15:17 +00:00
<?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;
2016-09-01 15:33:00 +00:00
/**
* Name of the level
* @var string
2016-09-01 16:05:47 +00:00
* @ORM\Column
2016-09-01 15:33:00 +00:00
*/
private $name;
2016-09-01 10:15:17 +00:00
/**
2016-09-01 15:33:00 +00:00
* @ORM\OneToMany(targetEntity="Target", mappedBy="level", cascade={"persist"})
2016-09-01 10:15:17 +00:00
*/
private $targets;
/**
* @ORM\OneToMany(targetEntity="Game", mappedBy="level", fetch="EXTRA_LAZY")
*/
private $games;
public function __construct()
{
$this->targets = new ArrayCollection();
$this->games = new ArrayCollection();
}
2016-09-01 15:33:00 +00:00
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;
}
2016-09-03 22:55:36 +00:00
/**
* Gets the value of id.
*
* @return integer
*/
public function getId()
{
return $this->id;
}
2016-09-01 10:15:17 +00:00
}