<?php
namespace App\Entity;
use App\Repository\FenceFaceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
/**
* @ORM\Entity(repositoryClass=FenceFaceRepository::class)
*/
class FenceFace
{
/**
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=FenceOffer::class, inversedBy="fenceFaces")
*/
private $fenceOffer;
/**
* @ORM\OneToMany(targetEntity=FenceOfferElement::class, mappedBy="fenceFace", cascade={"remove", "persist"}, orphanRemoval=true)
*/
private $fenceOfferElements;
/**
* @ORM\OneToMany(targetEntity=File::class, mappedBy="fenceFace", cascade={"remove"})
*/
private $files;
/**
* @ORM\ManyToOne(targetEntity=FenceElementDictionary::class)
* @ORM\JoinColumn(nullable=false)
*/
private $pole;
/**
* @ORM\Column(type="integer")
*/
private $totalLength;
/**
* @ORM\Column(type="integer")
*/
private $height;
/**
* @ORM\Column(type="integer")
*/
private $poleHeight;
/**
* @ORM\Column(type="boolean")
*/
private $startPole;
/**
* @ORM\Column(type="boolean")
*/
private $endPole;
/**
* @ORM\ManyToOne(targetEntity=Standard::class)
*/
private $standard;
public function __construct()
{
$this->fenceOfferElements = new ArrayCollection();
$this->files = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getFenceOffer(): ?FenceOffer
{
return $this->fenceOffer;
}
public function setFenceOffer(?FenceOffer $fenceOffer): self
{
$this->fenceOffer = $fenceOffer;
return $this;
}
/**
* @return Collection<int, FenceOfferElement>
*/
public function getFenceOfferElements(): Collection
{
$sortedElements = $this->fenceOfferElements->toArray();
usort($sortedElements, function (FenceOfferElement $a, FenceOfferElement $b) {
if ($a->getSortOrder() == $b->getSortOrder()) {
return 0;
}
return ($a->getSortOrder() < $b->getSortOrder()) ? -1 : 1;
});
return new ArrayCollection($sortedElements);
// return $this->fenceOfferElements;
}
public function addFenceOfferElement(FenceOfferElement $fenceOfferElement): self
{
if (!$this->fenceOfferElements->contains($fenceOfferElement)) {
$this->fenceOfferElements[] = $fenceOfferElement;
$fenceOfferElement->setFenceFace($this);
}
return $this;
}
public function removeFenceOfferElement(FenceOfferElement $fenceOfferElement): self
{
if ($this->fenceOfferElements->removeElement($fenceOfferElement)) {
// set the owning side to null (unless already changed)
if ($fenceOfferElement->getFenceFace() === $this) {
$fenceOfferElement->setFenceFace(null);
}
}
return $this;
}
/**
* @return Collection<int, File>
*/
public function getFiles(): Collection
{
return $this->files;
}
public function addFile(File $file): self
{
if (!$this->files->contains($file)) {
$this->files[] = $file;
$file->setFenceFace($this);
}
return $this;
}
public function removeFile(File $file): self
{
if ($this->files->removeElement($file)) {
// set the owning side to null (unless already changed)
if ($file->getFenceFace() === $this) {
$file->setFenceFace(null);
}
}
return $this;
}
public function getPole(): ?FenceElementDictionary
{
return $this->pole;
}
public function setPole(?FenceElementDictionary $pole): self
{
$this->pole = $pole;
return $this;
}
public function getTotalLength(): ?int
{
return $this->totalLength;
}
public function setTotalLength(int $totalLength): self
{
$this->totalLength = $totalLength;
return $this;
}
public function getHeight(): ?int
{
return $this->height;
}
public function setHeight(int $height): self
{
$this->height = $height;
return $this;
}
public function getPoleHeight(): ?int
{
return $this->poleHeight;
}
public function setPoleHeight(int $poleHeight): self
{
$this->poleHeight = $poleHeight;
return $this;
}
public function isStartPole(): ?bool
{
return $this->startPole;
}
public function setStartPole(bool $startPole): self
{
$this->startPole = $startPole;
return $this;
}
public function isEndPole(): ?bool
{
return $this->endPole;
}
public function setEndPole(bool $endPole): self
{
$this->endPole = $endPole;
return $this;
}
public function getStandard(): ?Standard
{
return $this->standard;
}
public function setStandard(?Standard $standard): self
{
$this->standard = $standard;
return $this;
}
}