src/Entity/Pest.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Translation\AutoTranslatableTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  8. #[ORM\Table(name'pest')]
  9. #[ORM\Entity(repositoryClass'App\Entity\Repository\PestRepository')]
  10. class Pest implements TranslatableInterface
  11. {
  12.     use AutoTranslatableTrait;
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'integer')]
  15.     #[ORM\GeneratedValue(strategy'AUTO')]
  16.     private $id;
  17.     #[ORM\Column(type'string'nullablefalse)]
  18.     private $name;
  19.     #[ORM\Column(type'string'nullabletrue)]
  20.     private $latin_name;
  21.     #[ORM\Column(type'string'nullabletrue)]
  22.     private $identifier;
  23.     #[ORM\Column(type'string'nullabletrue)]
  24.     private $category;
  25.     #[ORM\Column(type'text'nullabletrue)]
  26.     private $description;
  27.     #[ORM\Column(type'text'nullabletrue)]
  28.     private $countermeasure;
  29.     #[ORM\Column(type'datetime'nullabletrue)]
  30.     private $date_created;
  31.     #[ORM\OneToMany(targetEntity'App\Entity\CropPest'mappedBy'pest')]
  32.     private $cropPest;
  33.     #[ORM\OneToMany(targetEntityPestTranslation::class, mappedBy'translatable'orphanRemovaltrue)]
  34.     private $pestTranslation;
  35.     #[ORM\Column(type'json'nullabletrue)]
  36.     private $content_blocks = [];
  37.     #[ORM\Column(type'json'nullabletrue)]
  38.     private $content_options = [];
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private $external_id;
  41.     public function __construct()
  42.     {
  43.         $this->cropPest = new ArrayCollection();
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(bool $skipTranslation false): ?string
  50.     {
  51.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  52.             return $this->name;
  53.         }
  54.         $translated $this->translate()->getName();
  55.         return !empty($translated) ? $translated $this->name;
  56.     }
  57.     public function setName(string $name): self
  58.     {
  59.         $this->name $name;
  60.         return $this;
  61.     }
  62.     public function getDescription(): ?string
  63.     {
  64.         return $this->description;
  65.     }
  66.     public function setDescription(?string $description): self
  67.     {
  68.         $this->description $description;
  69.         return $this;
  70.     }
  71.     public function getCountermeasure(): ?string
  72.     {
  73.         return $this->countermeasure;
  74.     }
  75.     public function setCountermeasure(?string $countermeasure): self
  76.     {
  77.         $this->countermeasure $countermeasure;
  78.         return $this;
  79.     }
  80.     public function getDateCreated(): ?\DateTimeInterface
  81.     {
  82.         return $this->date_created;
  83.     }
  84.     public function setDateCreated(?\DateTimeInterface $date_created): self
  85.     {
  86.         $this->date_created $date_created;
  87.         return $this;
  88.     }
  89.     /**
  90.      * @return Collection|CropPest[]
  91.      */
  92.     public function getCropPest(): Collection
  93.     {
  94.         return $this->cropPest;
  95.     }
  96.     public function addCropPest(CropPest $cropPest): self
  97.     {
  98.         if (!$this->cropPest->contains($cropPest)) {
  99.             $this->cropPest[] = $cropPest;
  100.             $cropPest->setPest($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function removeCropPest(CropPest $cropPest): self
  105.     {
  106.         if ($this->cropPest->contains($cropPest)) {
  107.             $this->cropPest->removeElement($cropPest);
  108.             // set the owning side to null (unless already changed)
  109.             if ($cropPest->getPest() === $this) {
  110.                 $cropPest->setPest(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115.     public function getIdentifier(): ?string
  116.     {
  117.         return $this->identifier;
  118.     }
  119.     public function setIdentifier(?string $identifier): self
  120.     {
  121.         $this->identifier $identifier;
  122.         return $this;
  123.     }
  124.     public function getCategory(): ?string
  125.     {
  126.         return $this->category;
  127.     }
  128.     public function setCategory(?string $category): self
  129.     {
  130.         $this->category $category;
  131.         return $this;
  132.     }
  133.     public function getLatinName(): ?string
  134.     {
  135.         return $this->latin_name;
  136.     }
  137.     public function setLatinName(?string $latin_name): self
  138.     {
  139.         $this->latin_name $latin_name;
  140.         return $this;
  141.     }
  142.     public function getContentBlocks(bool $skipTranslation false): ?array
  143.     {
  144.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  145.             return $this->content_blocks;
  146.         }
  147.         $translated $this->translate()->getContentBlocks();
  148.         return !empty($translated) ? $translated $this->content_blocks;
  149.     }
  150.     public function setContentBlocks(?array $content_blocks): self
  151.     {
  152.         $this->content_blocks $content_blocks;
  153.         return $this;
  154.     }
  155.     public function getContentOptions(): ?array
  156.     {
  157.         return $this->content_options;
  158.     }
  159.     public function setContentOptions(?array $content_options): self
  160.     {
  161.         $this->content_options $content_options;
  162.         return $this;
  163.     }
  164.     public function getExternalId(): ?string
  165.     {
  166.         return $this->external_id;
  167.     }
  168.     public function setExternalId(?string $external_id): self
  169.     {
  170.         $this->external_id $external_id;
  171.         return $this;
  172.     }
  173. }