<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Simulation
*
* @ORM\Table(name="simulation")
* @ORM\Entity(repositoryClass="App\Repository\SimulationRepository")
* @ORM\HasLifecycleCallbacks()
*/
class Simulation
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
* @Assert\NotBlank
*/
private $name;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
* @var DateTime
*
* @ORM\Column(name="updatedAt", type="datetime")
*/
private $updatedAt;
/**
* @var bool
*
* @ORM\Column(name="visible", type="boolean", nullable=true)
*/
private $visible;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=true)
*/
protected $author;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SimulationLine", mappedBy="simulation", cascade={"all"}, orphanRemoval=true)
* @Assert\Valid
* @ORM\OrderBy({"priority" = "ASC"})
*/
protected $lines;
public function __construct()
{
$this->lines = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return Simulation
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
* @ORM\PreUpdate
*/
public function setUpdatedAt()
{
$this->updatedAt = new DateTime();
return $this;
}
/**
* Get updatedAt
*
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set visible
*
* @param boolean $visible
*
* @return Simulation
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* Get visible
*
* @return bool
*/
public function getVisible()
{
return $this->visible;
}
/**
* @return mixed
*/
public function getAuthor()
{
return $this->author;
}
/**
* @param mixed $author
*/
public function setAuthor($author)
{
$this->author = $author;
}
/**
* @return mixed
*/
public function getLines()
{
return $this->lines;
}
/**
* @param mixed $lines
*/
public function setLines($lines)
{
$this->lines = $lines;
}
public function addLine(SimulationLine $line)
{
$this->lines->add($line);
$line->setSimulation($this);
return $this;
}
public function removeLine(SimulationLine $line)
{
$this->lines->removeElement($line);
$line->setProduct(null);
return $this;
}
}