src/Entity/FenceFace.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\FenceFaceRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass=FenceFaceRepository::class)
  10.  */
  11. class FenceFace
  12. {
  13.     /**
  14.      * Hook timestampable behavior
  15.      * updates createdAt, updatedAt fields
  16.      */
  17.     use TimestampableEntity;
  18.     
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      */
  28.     private $name;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity=FenceOffer::class, inversedBy="fenceFaces")
  31.      */
  32.     private $fenceOffer;
  33.     /**
  34.      * @ORM\OneToMany(targetEntity=FenceOfferElement::class, mappedBy="fenceFace", cascade={"remove", "persist"}, orphanRemoval=true)
  35.      */
  36.     private $fenceOfferElements;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=File::class, mappedBy="fenceFace", cascade={"remove"})
  39.      */
  40.     private $files;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity=FenceElementDictionary::class)
  43.      * @ORM\JoinColumn(nullable=false)
  44.      */
  45.     private $pole;
  46.     /**
  47.      * @ORM\Column(type="integer")
  48.      */
  49.     private $totalLength;
  50.     /**
  51.      * @ORM\Column(type="integer")
  52.      */
  53.     private $height;
  54.     
  55.     /**
  56.      * @ORM\Column(type="integer")
  57.      */
  58.     private $poleHeight;
  59.     /**
  60.      * @ORM\Column(type="boolean")
  61.      */
  62.     private $startPole;
  63.     /**
  64.      * @ORM\Column(type="boolean")
  65.      */
  66.     private $endPole;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity=Standard::class)
  69.      */
  70.     private $standard;
  71.     public function __construct()
  72.     {
  73.         $this->fenceOfferElements = new ArrayCollection();
  74.         $this->files = new ArrayCollection();
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getName(): ?string
  81.     {
  82.         return $this->name;
  83.     }
  84.     public function setName(string $name): self
  85.     {
  86.         $this->name $name;
  87.         return $this;
  88.     }
  89.     public function getFenceOffer(): ?FenceOffer
  90.     {
  91.         return $this->fenceOffer;
  92.     }
  93.     public function setFenceOffer(?FenceOffer $fenceOffer): self
  94.     {
  95.         $this->fenceOffer $fenceOffer;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, FenceOfferElement>
  100.      */
  101.     public function getFenceOfferElements(): Collection
  102.     {
  103.         $sortedElements $this->fenceOfferElements->toArray();
  104.         usort($sortedElements, function (FenceOfferElement $aFenceOfferElement $b) {
  105.             if ($a->getSortOrder() == $b->getSortOrder()) {
  106.                 return 0;
  107.             }
  108.             return ($a->getSortOrder() < $b->getSortOrder()) ? -1;
  109.         });
  110.         return new ArrayCollection($sortedElements);
  111.         // return $this->fenceOfferElements;
  112.     }
  113.     public function addFenceOfferElement(FenceOfferElement $fenceOfferElement): self
  114.     {
  115.         if (!$this->fenceOfferElements->contains($fenceOfferElement)) {
  116.             $this->fenceOfferElements[] = $fenceOfferElement;
  117.             $fenceOfferElement->setFenceFace($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeFenceOfferElement(FenceOfferElement $fenceOfferElement): self
  122.     {
  123.         if ($this->fenceOfferElements->removeElement($fenceOfferElement)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($fenceOfferElement->getFenceFace() === $this) {
  126.                 $fenceOfferElement->setFenceFace(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131.     /**
  132.      * @return Collection<int, File>
  133.      */
  134.     public function getFiles(): Collection
  135.     {
  136.         return $this->files;
  137.     }
  138.     public function addFile(File $file): self
  139.     {
  140.         if (!$this->files->contains($file)) {
  141.             $this->files[] = $file;
  142.             $file->setFenceFace($this);
  143.         }
  144.         return $this;
  145.     }
  146.     public function removeFile(File $file): self
  147.     {
  148.         if ($this->files->removeElement($file)) {
  149.             // set the owning side to null (unless already changed)
  150.             if ($file->getFenceFace() === $this) {
  151.                 $file->setFenceFace(null);
  152.             }
  153.         }
  154.         return $this;
  155.     }
  156.     public function getPole(): ?FenceElementDictionary
  157.     {
  158.         return $this->pole;
  159.     }
  160.     public function setPole(?FenceElementDictionary $pole): self
  161.     {
  162.         $this->pole $pole;
  163.         return $this;
  164.     }
  165.     public function getTotalLength(): ?int
  166.     {
  167.         return $this->totalLength;
  168.     }
  169.     public function setTotalLength(int $totalLength): self
  170.     {
  171.         $this->totalLength $totalLength;
  172.         return $this;
  173.     }
  174.     public function getHeight(): ?int
  175.     {
  176.         return $this->height;
  177.     }
  178.     public function setHeight(int $height): self
  179.     {
  180.         $this->height $height;
  181.         return $this;
  182.     }
  183.     public function getPoleHeight(): ?int
  184.     {
  185.         return $this->poleHeight;
  186.     }
  187.     public function setPoleHeight(int $poleHeight): self
  188.     {
  189.         $this->poleHeight $poleHeight;
  190.         return $this;
  191.     }
  192.     public function isStartPole(): ?bool
  193.     {
  194.         return $this->startPole;
  195.     }
  196.     public function setStartPole(bool $startPole): self
  197.     {
  198.         $this->startPole $startPole;
  199.         return $this;
  200.     }
  201.     public function isEndPole(): ?bool
  202.     {
  203.         return $this->endPole;
  204.     }
  205.     public function setEndPole(bool $endPole): self
  206.     {
  207.         $this->endPole $endPole;
  208.         return $this;
  209.     }
  210.     public function getStandard(): ?Standard
  211.     {
  212.         return $this->standard;
  213.     }
  214.     public function setStandard(?Standard $standard): self
  215.     {
  216.         $this->standard $standard;
  217.         return $this;
  218.     }
  219. }