src/Entity/ScreenType.php line 52

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JsonSerializable;
  8. /**
  9. * @ApiResource()
  10. * @ORM\Entity
  11. * @ORM\Table(name="screen_types")
  12. * @package App\Entity
  13. */
  14. class ScreenType implements JsonSerializable
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=128, nullable=true)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $fileExtension;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity="App\Entity\Screen", mappedBy="screenType", fetch="EXTRA_LAZY", cascade={"persist"})
  32.      * @ORM\OrderBy({"name" = "ASC"})
  33.      */
  34.     private $screens;
  35.     public function __construct()
  36.     {
  37.         $this->points = new ArrayCollection();
  38.     }
  39.     public function __toString()
  40.     {
  41.         return (string) $this->getName();
  42.     }
  43.     public function jsonSerialize()
  44.     {
  45.         return array(
  46.             'id'=> $this->id,
  47.             'name' => $this->name,
  48.             'fileExtension' => $this->fileExtension,
  49.             // 'dateAdded' => $this->dateAdded,
  50.             // 'dateModified' => $this->dateModified,
  51.         );
  52.     }
  53.     /**
  54.      * get id
  55.      *
  56.      * @return integer
  57.      */
  58.     public function getId()
  59.     {
  60.         return $this->id;
  61.     }
  62.     /**
  63.      * get name
  64.      *
  65.      * @return string
  66.      */
  67.     public function getName()
  68.     {
  69.         return $this->name;
  70.     }
  71.     /**
  72.      * set name
  73.      *
  74.      * @param string $name
  75.      *
  76.      * @return ScreenType
  77.      */
  78.     public function setName($name)
  79.     {
  80.         $this->name $name;
  81.         return $this;
  82.     }
  83.     /**
  84.      * get fileExtension
  85.      *
  86.      * @return string
  87.      */
  88.     public function getFileExtension()
  89.     {
  90.         return $this->fileExtension;
  91.     }
  92.     /**
  93.      * set fileExtension
  94.      *
  95.      * @param string $fileExtension
  96.      *
  97.      * @return Screen
  98.      */
  99.     public function setFileExtension($fileExtension)
  100.     {
  101.         $this->fileExtension $fileExtension;
  102.         return $this;
  103.     }
  104.     /**
  105.      * get screens
  106.      *
  107.      * @return Collection|Point[]
  108.      */
  109.     public function getScreens()
  110.     {
  111.         return $this->screens;
  112.     }
  113.     public function addScreen(\App\Entity\Screen $screen)
  114.     {
  115.         if (!$this->screens->contains($screen)) {
  116.             $this->screens[] = $screen;
  117.             $screen->setScreenType($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removePoint(\App\Entity\Screen $screen)
  122.     {
  123.         if ($this->screens->contains($screen)) {
  124.             $this->screens->removeElement($screen);
  125.             // set the owning side to null (unless already changed)
  126.             if ($screen->getScreenType() === $this) {
  127.                 $screen->setScreenType(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132. }