src/Entity/Simulation.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * Simulation
  9.  *
  10.  * @ORM\Table(name="simulation")
  11.  * @ORM\Entity(repositoryClass="App\Repository\SimulationRepository")
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class Simulation
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="name", type="string", length=255)
  28.      * @Assert\NotBlank
  29.      */
  30.     private $name;
  31.     /**
  32.      * @var DateTime
  33.      *
  34.      * @ORM\Column(name="createdAt", type="datetime")
  35.      */
  36.     private $createdAt;
  37.     /**
  38.      * @var DateTime
  39.      *
  40.      * @ORM\Column(name="updatedAt", type="datetime")
  41.      */
  42.     private $updatedAt;
  43.     /**
  44.      * @var bool
  45.      *
  46.      * @ORM\Column(name="visible", type="boolean", nullable=true)
  47.      */
  48.     private $visible;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity="App\Entity\User")
  51.      * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=true)
  52.      */
  53.     protected $author;
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="App\Entity\SimulationLine", mappedBy="simulation", cascade={"all"}, orphanRemoval=true)
  56.      * @Assert\Valid
  57.      * @ORM\OrderBy({"priority" = "ASC"})
  58.      */
  59.     protected $lines;
  60.     public function __construct()
  61.     {
  62.         $this->lines = new ArrayCollection();
  63.     }
  64.     public function __toString()
  65.     {
  66.         return $this->name;
  67.     }
  68.     /**
  69.      * Get id
  70.      *
  71.      * @return int
  72.      */
  73.     public function getId()
  74.     {
  75.         return $this->id;
  76.     }
  77.     /**
  78.      * Set name
  79.      *
  80.      * @param string $name
  81.      *
  82.      * @return Simulation
  83.      */
  84.     public function setName($name)
  85.     {
  86.         $this->name $name;
  87.         return $this;
  88.     }
  89.     /**
  90.      * Get name
  91.      *
  92.      * @return string
  93.      */
  94.     public function getName()
  95.     {
  96.         return $this->name;
  97.     }
  98.     /**
  99.      * @ORM\PrePersist
  100.      */
  101.     public function setCreatedAt()
  102.     {
  103.         $this->createdAt = new DateTime();
  104.         $this->updatedAt = new DateTime();
  105.         return $this;
  106.     }
  107.     /**
  108.      * Get createdAt
  109.      *
  110.      * @return DateTime
  111.      */
  112.     public function getCreatedAt()
  113.     {
  114.         return $this->createdAt;
  115.     }
  116.     /**
  117.      * Set updatedAt
  118.      * @ORM\PreUpdate
  119.      */
  120.     public function setUpdatedAt()
  121.     {
  122.         $this->updatedAt = new DateTime();
  123.         return $this;
  124.     }
  125.     /**
  126.      * Get updatedAt
  127.      *
  128.      * @return DateTime
  129.      */
  130.     public function getUpdatedAt()
  131.     {
  132.         return $this->updatedAt;
  133.     }
  134.     /**
  135.      * Set visible
  136.      *
  137.      * @param boolean $visible
  138.      *
  139.      * @return Simulation
  140.      */
  141.     public function setVisible($visible)
  142.     {
  143.         $this->visible $visible;
  144.         return $this;
  145.     }
  146.     /**
  147.      * Get visible
  148.      *
  149.      * @return bool
  150.      */
  151.     public function getVisible()
  152.     {
  153.         return $this->visible;
  154.     }
  155.     /**
  156.      * @return mixed
  157.      */
  158.     public function getAuthor()
  159.     {
  160.         return $this->author;
  161.     }
  162.     /**
  163.      * @param mixed $author
  164.      */
  165.     public function setAuthor($author)
  166.     {
  167.         $this->author $author;
  168.     }
  169.     /**
  170.      * @return mixed
  171.      */
  172.     public function getLines()
  173.     {
  174.         return $this->lines;
  175.     }
  176.     /**
  177.      * @param mixed $lines
  178.      */
  179.     public function setLines($lines)
  180.     {
  181.         $this->lines $lines;
  182.     }
  183.     public function addLine(SimulationLine $line)
  184.     {
  185.         $this->lines->add($line);
  186.         $line->setSimulation($this);
  187.         return $this;
  188.     }
  189.     public function removeLine(SimulationLine $line)
  190.     {
  191.         $this->lines->removeElement($line);
  192.         $line->setProduct(null);
  193.         return $this;
  194.     }
  195. }