src/Entity/Property.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PropertyRepository;
  4. use App\Translation\AutoTranslatableTrait;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. #[ORM\Entity(repositoryClassPropertyRepository::class)]
  10. class Property implements TranslatableInterface
  11. {
  12.     use AutoTranslatableTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private $id;
  17.     #[ORM\Column(type'string'length255)]
  18.     private $name;
  19.     #[ORM\Column(type'datetime')]
  20.     private $created_at;
  21.     #[ORM\Column(type'datetime'nullabletrue)]
  22.     private $updated_at;
  23.     #[ORM\ManyToOne(targetEntityPropertygroup::class, inversedBy'properties')]
  24.     private $propertygroup;
  25.     #[ORM\OneToMany(targetEntityCropProperty::class, mappedBy'property')]
  26.     private $cropProperties;
  27.     public function __construct()
  28.     {
  29.         $this->created_at = new \DateTime();
  30.         $this->cropProperties = new ArrayCollection();
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getName(bool $skipTranslation false): ?string
  37.     {
  38.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  39.             return $this->name;
  40.         }
  41.         $translated $this->translate()->getName();
  42.         return !empty($translated) ? $translated $this->name;
  43.     }
  44.     public function setName(string $name): self
  45.     {
  46.         $this->name $name;
  47.         return $this;
  48.     }
  49.     public function getCreatedAt(): ?\DateTimeInterface
  50.     {
  51.         return $this->created_at;
  52.     }
  53.     public function setCreatedAt(\DateTimeInterface $created_at): self
  54.     {
  55.         $this->created_at $created_at;
  56.         return $this;
  57.     }
  58.     public function getUpdatedAt(): ?\DateTimeInterface
  59.     {
  60.         return $this->updated_at;
  61.     }
  62.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  63.     {
  64.         $this->updated_at $updated_at;
  65.         return $this;
  66.     }
  67.     public function getPropertygroup(): ?Propertygroup
  68.     {
  69.         return $this->propertygroup;
  70.     }
  71.     public function setPropertygroup(?Propertygroup $propertygroup): self
  72.     {
  73.         $this->propertygroup $propertygroup;
  74.         return $this;
  75.     }
  76.     /**
  77.      * @return Collection<int, CropProperty>
  78.      */
  79.     public function getCropProperties(): Collection
  80.     {
  81.         return $this->cropProperties;
  82.     }
  83.     public function addCropProperty(CropProperty $cropProperty): self
  84.     {
  85.         if (!$this->cropProperties->contains($cropProperty)) {
  86.             $this->cropProperties[] = $cropProperty;
  87.             $cropProperty->setProperty($this);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeCropProperty(CropProperty $cropProperty): self
  92.     {
  93.         if ($this->cropProperties->removeElement($cropProperty)) {
  94.             // set the owning side to null (unless already changed)
  95.             if ($cropProperty->getProperty() === $this) {
  96.                 $cropProperty->setProperty(null);
  97.             }
  98.         }
  99.         return $this;
  100.     }
  101. }