src/Entity/Patch.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Table(name'patch')]
  7. #[ORM\Index(name'ix_uuid'columns: ['uuid'])]
  8. #[ORM\Entity(repositoryClass'App\Entity\Repository\PatchRepository')]
  9. class Patch
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(type'integer')]
  13.     #[ORM\GeneratedValue(strategy'AUTO')]
  14.     private $id;
  15.     #[ORM\Column(type'string'nullabletrue)]
  16.     private $name;
  17.     #[ORM\Column(type'json'nullabletrue)]
  18.     private $microclimate;
  19.     #[ORM\Column(type'json'nullabletrue)]
  20.     private $location;
  21.     #[ORM\Column(type'integer'nullabletrue)]
  22.     private $width;
  23.     #[ORM\Column(type'integer'nullabletrue)]
  24.     private $length;
  25.     #[ORM\Column(type'integer'nullabletrue)]
  26.     private $amount_rows;
  27.     #[ORM\Column(type'integer'nullabletrue)]
  28.     private $amount_cols;
  29.     #[ORM\Column(type'integer'nullabletrue)]
  30.     private $rasterSize;
  31.     #[ORM\Column(type'boolean'nullabletrue)]
  32.     private $initialized;
  33.     #[ORM\Column(type'json'nullabletrue)]
  34.     private $settings;
  35.     /**
  36.      *
  37.      */
  38.     private $rows;
  39.     /**
  40.      *
  41.      */
  42.     private $cols;
  43.     #[ORM\Column(type'string'nullabletrue)]
  44.     private $shape;
  45.     #[ORM\Column(type'datetime'nullablefalse)]
  46.     private $date_created;
  47.     #[ORM\Column(type'datetime'nullabletrue)]
  48.     private $date_updated;
  49.     #[ORM\Column(type'integer'nullabletrue)]
  50.     private $position_x;
  51.     #[ORM\Column(type'integer'nullabletrue)]
  52.     private $position_y;
  53.     #[ORM\OneToMany(targetEntity'App\Entity\Patch'mappedBy'parentPatch')]
  54.     private $childPatch;
  55.     #[ORM\OneToMany(targetEntity'App\Entity\Patchfield'mappedBy'patch')]
  56.     private $patchfield;
  57.     /**
  58.      *
  59.      */
  60.     private $patchCrop;
  61.     #[ORM\OneToMany(targetEntity'App\Entity\PatchfieldGroup'mappedBy'patch')]
  62.     private $patchfieldGroup;
  63.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'patch')]
  64.     #[ORM\JoinColumn(name'user_id'referencedColumnName'id'nullablefalse)]
  65.     private $user;
  66.     #[ORM\ManyToOne(targetEntity'App\Entity\Patch'inversedBy'childPatch')]
  67.     #[ORM\JoinColumn(name'patch_id'referencedColumnName'id')]
  68.     private $parentPatch;
  69.     #[ORM\OneToMany(targetEntityPlant::class, mappedBy'patch')]
  70.     private $plants;
  71.     #[ORM\Column(type'boolean'nullabletrue)]
  72.     private $isNewPlan;
  73.     #[ORM\Column(type'guid'nullabletrue)]
  74.     private $uuid;
  75.     #[ORM\Column(type'json'nullabletrue)]
  76.     private $data = [];
  77.     #[ORM\ManyToOne(targetEntityGarden::class, inversedBy'patches')]
  78.     private $garden;
  79.     public function __construct()
  80.     {
  81.         $this->patchCrop = new ArrayCollection();
  82.         $this->patchfieldGroup = new ArrayCollection();
  83.         $this->patchfield = new ArrayCollection();
  84.         $this->childPatch = new ArrayCollection();
  85.         $this->plants = new ArrayCollection();
  86.         $this->date_created = new \DateTime();
  87.     }
  88.     public function __clone() {
  89.         $this->id null;
  90.         $this->patchCrop = new ArrayCollection();
  91.         $this->patchfieldGroup = new ArrayCollection();
  92.         $this->patchfield = new ArrayCollection();
  93.         $this->childPatch = new ArrayCollection();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getName(): ?string
  100.     {
  101.         if( empty($this->name) && isset($this->data['name']) ) {
  102.             return $this->data['name'];
  103.         }
  104.         return $this->name;
  105.     }
  106.     public function setName(?string $name): self
  107.     {
  108.         $this->name $name;
  109.         return $this;
  110.     }
  111.     public function getMicroclimate()
  112.     {
  113.         return $this->microclimate;
  114.     }
  115.     public function setMicroclimate($microclimate): self
  116.     {
  117.         $this->microclimate $microclimate;
  118.         return $this;
  119.     }
  120.     public function getWidth(): ?int
  121.     {
  122.         return $this->width;
  123.     }
  124.     public function setWidth(?int $width): self
  125.     {
  126.         $this->width $width;
  127.         return $this;
  128.     }
  129.     public function getLength(): ?int
  130.     {
  131.         return $this->length;
  132.     }
  133.     public function setLength(?int $length): self
  134.     {
  135.         $this->length $length;
  136.         return $this;
  137.     }
  138.     public function getShape(): ?string
  139.     {
  140.         return $this->shape;
  141.     }
  142.     public function setShape(?string $shape): self
  143.     {
  144.         $this->shape $shape;
  145.         return $this;
  146.     }
  147.     public function getDateCreated(): ?\DateTimeInterface
  148.     {
  149.         return $this->date_created;
  150.     }
  151.     public function setDateCreated(\DateTimeInterface $date_created): self
  152.     {
  153.         $this->date_created $date_created;
  154.         return $this;
  155.     }
  156.     /**
  157.      * @return Collection|Patchfield[]
  158.      */
  159.     public function getPatchCrop(): Collection
  160.     {
  161.         return $this->patchCrop;
  162.     }
  163.     public function addPatchCrop(Patchfield $patchCrop): self
  164.     {
  165.         if (!$this->patchCrop->contains($patchCrop)) {
  166.             $this->patchCrop[] = $patchCrop;
  167.             $patchCrop->setPatch($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removePatchCrop(Patchfield $patchCrop): self
  172.     {
  173.         if ($this->patchCrop->contains($patchCrop)) {
  174.             $this->patchCrop->removeElement($patchCrop);
  175.             // set the owning side to null (unless already changed)
  176.             if ($patchCrop->getPatch() === $this) {
  177.                 $patchCrop->setPatch(null);
  178.             }
  179.         }
  180.         return $this;
  181.     }
  182.     public function getUser(): ?User
  183.     {
  184.         return $this->user;
  185.     }
  186.     public function setUser(?User $user): self
  187.     {
  188.         $this->user $user;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return Collection|PatchfieldGroup[]
  193.      */
  194.     public function getPatchfieldGroup(): Collection
  195.     {
  196.         return $this->patchfieldGroup;
  197.     }
  198.     public function addPatchfieldGroup(PatchfieldGroup $patchfieldGroup): self
  199.     {
  200.         if (!$this->patchfieldGroup->contains($patchfieldGroup)) {
  201.             $this->patchfieldGroup[] = $patchfieldGroup;
  202.             $patchfieldGroup->setPatch($this);
  203.         }
  204.         return $this;
  205.     }
  206.     public function removePatchfieldGroup(PatchfieldGroup $patchfieldGroup): self
  207.     {
  208.         if ($this->patchfieldGroup->contains($patchfieldGroup)) {
  209.             $this->patchfieldGroup->removeElement($patchfieldGroup);
  210.             // set the owning side to null (unless already changed)
  211.             if ($patchfieldGroup->getPatch() === $this) {
  212.                 $patchfieldGroup->setPatch(null);
  213.             }
  214.         }
  215.         return $this;
  216.     }
  217.     public function getAmountRows(): ?int
  218.     {
  219.         return $this->amount_rows;
  220.     }
  221.     public function setAmountRows(?int $amount_rows): self
  222.     {
  223.         $this->amount_rows $amount_rows;
  224.         return $this;
  225.     }
  226.     public function getAmountCols(): ?int
  227.     {
  228.         return $this->amount_cols;
  229.     }
  230.     public function setAmountCols(?int $amount_cols): self
  231.     {
  232.         $this->amount_cols $amount_cols;
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection|Patchfield[]
  237.      */
  238.     public function getPatchfield(): Collection
  239.     {
  240.         return $this->patchfield;
  241.     }
  242.     public function addPatchfield(Patchfield $patchfield): self
  243.     {
  244.         if (!$this->patchfield->contains($patchfield)) {
  245.             $this->patchfield[] = $patchfield;
  246.             $patchfield->setPatch($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removePatchfield(Patchfield $patchfield): self
  251.     {
  252.         if ($this->patchfield->contains($patchfield)) {
  253.             $this->patchfield->removeElement($patchfield);
  254.             // set the owning side to null (unless already changed)
  255.             if ($patchfield->getPatch() === $this) {
  256.                 $patchfield->setPatch(null);
  257.             }
  258.         }
  259.         return $this;
  260.     }
  261.     public function getDateUpdated(): ?\DateTimeInterface
  262.     {
  263.         return $this->date_updated;
  264.     }
  265.     public function setDateUpdated(?\DateTimeInterface $date_updated): self
  266.     {
  267.         $this->date_updated $date_updated;
  268.         return $this;
  269.     }
  270.     public function getInitialized(): ?bool
  271.     {
  272.         return $this->initialized;
  273.     }
  274.     public function setInitialized(?bool $initialized): self
  275.     {
  276.         $this->initialized $initialized;
  277.         return $this;
  278.     }
  279.     public function getLocation()
  280.     {
  281.         return $this->location;
  282.     }
  283.     public function setLocation($location): self
  284.     {
  285.         $this->location $location;
  286.         return $this;
  287.     }
  288.     public function getPositionX(): ?int
  289.     {
  290.         return $this->position_x;
  291.     }
  292.     public function setPositionX(?int $position_x): self
  293.     {
  294.         $this->position_x $position_x;
  295.         return $this;
  296.     }
  297.     public function getPositionY(): ?int
  298.     {
  299.         return $this->position_y;
  300.     }
  301.     public function setPositionY(?int $position_y): self
  302.     {
  303.         $this->position_y $position_y;
  304.         return $this;
  305.     }
  306.     /**
  307.      * @return Collection|Patch[]
  308.      */
  309.     public function getChildPatch(): Collection
  310.     {
  311.         return $this->childPatch;
  312.     }
  313.     public function addChildPatch(Patch $childPatch): self
  314.     {
  315.         if (!$this->childPatch->contains($childPatch)) {
  316.             $this->childPatch[] = $childPatch;
  317.             $childPatch->setParentPatch($this);
  318.         }
  319.         return $this;
  320.     }
  321.     public function removeChildPatch(Patch $childPatch): self
  322.     {
  323.         if ($this->childPatch->contains($childPatch)) {
  324.             $this->childPatch->removeElement($childPatch);
  325.             // set the owning side to null (unless already changed)
  326.             if ($childPatch->getParentPatch() === $this) {
  327.                 $childPatch->setParentPatch(null);
  328.             }
  329.         }
  330.         return $this;
  331.     }
  332.     public function getParentPatch(): ?self
  333.     {
  334.         return $this->parentPatch;
  335.     }
  336.     public function setParentPatch(?self $parentPatch): self
  337.     {
  338.         $this->parentPatch $parentPatch;
  339.         return $this;
  340.     }
  341.     public function getRasterSize(): ?int
  342.     {
  343.         return $this->rasterSize;
  344.     }
  345.     public function setRasterSize(?int $rasterSize): self
  346.     {
  347.         $this->rasterSize $rasterSize;
  348.         return $this;
  349.     }
  350.     public function getSettings()
  351.     {
  352.         return $this->settings;
  353.     }
  354.     public function setSettings($settings): self
  355.     {
  356.         $this->settings $settings;
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return Collection|Plant[]
  361.      */
  362.     public function getPlants(): Collection
  363.     {
  364.         return $this->plants;
  365.     }
  366.     public function addPlant(Plant $plant): self
  367.     {
  368.         if (!$this->plants->contains($plant)) {
  369.             $this->plants[] = $plant;
  370.             $plant->setPatch($this);
  371.         }
  372.         return $this;
  373.     }
  374.     public function removePlant(Plant $plant): self
  375.     {
  376.         if ($this->plants->removeElement($plant)) {
  377.             // set the owning side to null (unless already changed)
  378.             if ($plant->getPatch() === $this) {
  379.                 $plant->setPatch(null);
  380.             }
  381.         }
  382.         return $this;
  383.     }
  384.     public function getIsNewPlan(): ?bool
  385.     {
  386.         return $this->isNewPlan;
  387.     }
  388.     public function setIsNewPlan(?bool $isNewPlan): self
  389.     {
  390.         $this->isNewPlan $isNewPlan;
  391.         return $this;
  392.     }
  393.     public function getUuid(): ?string
  394.     {
  395.         return $this->uuid;
  396.     }
  397.     public function setUuid(?string $uuid): self
  398.     {
  399.         $this->uuid $uuid;
  400.         return $this;
  401.     }
  402.     public function getData(): ?array
  403.     {
  404.         return $this->data;
  405.     }
  406.     public function setData(?array $data): self
  407.     {
  408.         $this->data $data;
  409.         return $this;
  410.     }
  411.     public function getGarden(): ?Garden
  412.     {
  413.         return $this->garden;
  414.     }
  415.     public function setGarden(?Garden $garden): self
  416.     {
  417.         $this->garden $garden;
  418.         return $this;
  419.     }
  420. }