src/Entity/Crop.php line 15

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. #[ORM\Table(name'crop')]
  10. #[ORM\Index(name'IX_identifier'columns: ['identifier'])]
  11. #[ORM\Entity(repositoryClass'App\Entity\Repository\CropRepository')]
  12. class Crop implements TranslatableInterface
  13. {
  14.     use AutoTranslatableTrait;
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'integer')]
  17.     #[ORM\GeneratedValue(strategy'AUTO')]
  18.     private $id;
  19.     #[ORM\Column(type'string'nullabletrue)]
  20.     private $identifier;
  21.     #[ORM\Column(type'string'nullabletrue)]
  22.     private $name;
  23.     #[ORM\Column(type'string'nullabletrue)]
  24.     private $latin_name;
  25.     #[ORM\Column(type'text'nullabletrue)]
  26.     private $description;
  27.     #[ORM\Column(type'text'nullabletrue)]
  28.     private $short_description;
  29.     #[ORM\Column(type'string'nullabletrue)]
  30.     private $origin;
  31.     #[ORM\Column(type'json'nullabletrue)]
  32.     private $growing_tipps;
  33.     #[ORM\Column(type'string'nullabletrue)]
  34.     private $cultivation_cycles;
  35.     #[ORM\Column(type'json'nullabletrue)]
  36.     private $germination_duration;
  37.     #[ORM\Column(type'json'nullabletrue)]
  38.     private $germination_season;
  39.     #[ORM\Column(type'json'nullabletrue)]
  40.     private $precultivation_duration;
  41.     #[ORM\Column(type'json'nullabletrue)]
  42.     private $precultivation_season;
  43.     #[ORM\Column(type'boolean'nullabletrue)]
  44.     private $has_precultivation;
  45.     #[ORM\Column(type'json'nullabletrue)]
  46.     private $growth_duration;
  47.     #[ORM\Column(type'json'nullabletrue)]
  48.     private $growth_season;
  49.     #[ORM\Column(type'json'nullabletrue)]
  50.     private $harvest_duration;
  51.     #[ORM\Column(type'json'nullabletrue)]
  52.     private $harvest_season;
  53.     #[ORM\Column(type'json'nullabletrue)]
  54.     private $lightscore;
  55.     #[ORM\Column(type'integer'nullabletrue)]
  56.     private $grid_length;
  57.     #[ORM\Column(type'integer'nullabletrue)]
  58.     private $grid_width;
  59.     #[ORM\Column(type'float'nullabletrue)]
  60.     private $harvest_amount;
  61.     #[ORM\Column(type'string'nullabletrue)]
  62.     private $nutrient_demand;
  63.     #[ORM\Column(type'string'nullabletrue)]
  64.     private $lighting_demand;
  65.     #[ORM\Column(type'string'nullabletrue)]
  66.     private $water_demand;
  67.     #[ORM\Column(type'json'nullabletrue)]
  68.     private $seeding_depth;
  69.     #[ORM\Column(type'json'nullabletrue)]
  70.     private $seeding_distance;
  71.     #[ORM\Column(type'string'nullabletrue)]
  72.     private $spread;
  73.     #[ORM\Column(type'json'nullabletrue)]
  74.     private $compatibility;
  75.     #[ORM\Column(type'boolean'nullabletrue)]
  76.     private $plant_in_rows;
  77.     #[ORM\Column(type'boolean'nullabletrue)]
  78.     private $f1_hybrid;
  79.     #[ORM\Column(type'json'nullabletrue)]
  80.     private $row_distance;
  81.     #[ORM\Column(type'string'nullabletrue)]
  82.     private $fertilizer_type;
  83.     #[ORM\Column(type'json'nullabletrue)]
  84.     private $user_crop_settings;
  85.     #[ORM\Column(type'string'nullabletrue)]
  86.     private $ground_type;
  87.     #[ORM\Column(type'boolean'nullabletrue)]
  88.     private $cold_resistant;
  89.     #[ORM\Column(type'boolean'nullabletrue)]
  90.     private $is_shared;
  91.     #[ORM\Column(type'boolean'nullabletrue)]
  92.     private $is_approved;
  93.     #[ORM\Column(type'datetime'nullablefalse)]
  94.     private $date_created;
  95.     #[ORM\Column(type'datetime'nullabletrue)]
  96.     private $date_updated;
  97.     #[ORM\OneToMany(targetEntity'App\Entity\Crop'mappedBy'parentCrop')]
  98.     private $childCrop;
  99.     #[ORM\OneToMany(targetEntity'App\Entity\Patchfield'mappedBy'crop')]
  100.     private $patchCrop;
  101.     #[ORM\OneToMany(targetEntity'App\Entity\CropPest'mappedBy'crop')]
  102.     private $cropPest;
  103.     #[ORM\OneToMany(targetEntity'App\Entity\CropDisease'mappedBy'crop')]
  104.     private $cropDisease;
  105.     #[ORM\OneToMany(targetEntity'App\Entity\Cropaction'mappedBy'crop')]
  106.     private $cropaction;
  107.     #[ORM\OneToMany(targetEntity'App\Entity\PlanCrop'mappedBy'crop')]
  108.     private $planCrop;
  109.     #[ORM\OneToMany(targetEntity'App\Entity\ShoparticleCrop'mappedBy'crop')]
  110.     private $shoparticleCrop;
  111.     #[ORM\OneToMany(targetEntity'App\Entity\FavoriteCrop'mappedBy'crop')]
  112.     private $favoriteCrop;
  113.     #[ORM\OneToMany(targetEntity'App\Entity\CropSynonym'mappedBy'crop')]
  114.     private $cropSynonym;
  115.     #[ORM\OneToMany(targetEntity'App\Entity\CropEdit'mappedBy'crop')]
  116.     private $cropEdit;
  117.     #[ORM\OneToMany(targetEntity'App\Entity\CropRating'mappedBy'crop')]
  118.     private $cropRating;
  119.     #[ORM\ManyToOne(targetEntity'App\Entity\Cropcategory'inversedBy'crop')]
  120.     #[ORM\JoinColumn(name'cropcategory_id'referencedColumnName'id')]
  121.     private $cropcategory;
  122.     #[ORM\ManyToOne(targetEntity'App\Entity\Crop'inversedBy'childCrop')]
  123.     #[ORM\JoinColumn(name'parent_crop_id'referencedColumnName'id')]
  124.     private $parentCrop;
  125.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'crop')]
  126.     #[ORM\JoinColumn(name'user_id'referencedColumnName'id')]
  127.     private $user;
  128.     #[ORM\ManyToOne(targetEntity'App\Entity\Plantfamily'inversedBy'crop')]
  129.     #[ORM\JoinColumn(name'plantfamily_id'referencedColumnName'id')]
  130.     private $plantfamily;
  131.     #[ORM\Column(type'integer'nullabletrue)]
  132.     private $popularity;
  133.     #[ORM\Column(type'json'nullabletrue)]
  134.     private $seasons = [];
  135.     #[ORM\OneToMany(targetEntityCropProperty::class, mappedBy'crop'orphanRemovaltrue)]
  136.     private $cropProperties;
  137.     #[ORM\OneToMany(targetEntityCropTranslation::class, mappedBy'translatable'orphanRemovaltrue)]
  138.     private $cropTranslation;
  139.     #[ORM\Column(type'string'length255nullabletrue)]
  140.     private $dynamic_link;
  141.     #[ORM\Column(nullabletrue)]
  142.     private ?float $cultivation_break null;
  143.     #[ORM\Column(length10nullabletrue)]
  144.     private ?string $germination_type null;
  145.     #[ORM\Column(length10nullabletrue)]
  146.     private ?string $germination_temperature null;
  147.     #[ORM\Column(length255nullabletrue)]
  148.     private ?string $shop_category_url null;
  149.     #[ORM\Column(length50nullabletrue)]
  150.     private ?string $growth_habit null;
  151.     #[ORM\OneToMany(mappedBy'crop'targetEntityShoparticleBlockentry::class, orphanRemovaltrue)]
  152.     private Collection $shoparticleBlockentries;
  153.     #[ORM\Column(nullabletrue)]
  154.     private ?bool $isGreenManure null;
  155.     #[ORM\OneToMany(mappedBy'crop'targetEntityCropImage::class, orphanRemovaltrue)]
  156.     private Collection $cropImages;
  157.     #[ORM\ManyToOne]
  158.     private ?Climatezone $climatezone null;
  159.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  160.     private ?string $gtin_barcode null;
  161.     public function __construct()
  162.     {
  163.         $this->patchCrop = new ArrayCollection();
  164.         $this->cropPest = new ArrayCollection();
  165.         $this->cropDisease = new ArrayCollection();
  166.         $this->cropaction = new ArrayCollection();
  167.         $this->planCrop = new ArrayCollection();
  168.         $this->shoparticleCrop = new ArrayCollection();
  169.         $this->favoriteCrop = new ArrayCollection();
  170.         $this->childCrop = new ArrayCollection();
  171.         $this->cropSynonym = new ArrayCollection();
  172.         $this->cropEdit = new ArrayCollection();
  173.         $this->cropRating = new ArrayCollection();
  174.         $this->cropProperties = new ArrayCollection();
  175.         $this->shoparticleBlockentries = new ArrayCollection();
  176.         $this->cropImages = new ArrayCollection();
  177.     }
  178.     public function getId(): ?int
  179.     {
  180.         return $this->id;
  181.     }
  182.     public function getIdentifier(): ?string
  183.     {
  184.         return $this->identifier;
  185.     }
  186.     public function setIdentifier(?string $identifier): self
  187.     {
  188.         $this->identifier $identifier;
  189.         return $this;
  190.     }
  191.     public function getName(bool $skipTranslation false): ?string
  192.     {
  193.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  194.             return $this->name;
  195.         }
  196.         $translated $this->translate()->getName();
  197.         return !empty($translated) ? $translated $this->name;
  198.     }
  199.     public function setName(?string $name): self
  200.     {
  201.         $this->name $name;
  202.         return $this;
  203.     }
  204.     public function getLatinName(): ?string
  205.     {
  206.         return $this->latin_name;
  207.     }
  208.     public function setLatinName(?string $latin_name): self
  209.     {
  210.         $this->latin_name $latin_name;
  211.         return $this;
  212.     }
  213.     public function getDescription(bool $skipTranslation false): ?string
  214.     {
  215.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  216.             return $this->description;
  217.         }
  218.         $translated $this->translate()->getDescription();
  219.         return !empty($translated) ? $translated $this->description;
  220.     }
  221.     public function setDescription(?string $description): self
  222.     {
  223.         $this->description $description;
  224.         return $this;
  225.     }
  226.     public function getOrigin(bool $skipTranslation false): ?string
  227.     {
  228.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  229.             return $this->origin;
  230.         }
  231.         $translated $this->translate()->getOrigin();
  232.         return !empty($translated) ? $translated $this->origin;
  233.     }
  234.     public function setOrigin(?string $origin): self
  235.     {
  236.         $this->origin $origin;
  237.         return $this;
  238.     }
  239.     public function getGrowingTipps(bool $skipTranslation false)
  240.     {
  241.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  242.             return $this->growing_tipps;
  243.         }
  244.         $translated $this->translate()->getGrowingTipps();
  245.         return !empty($translated) ? $translated $this->growing_tipps;
  246.     }
  247.     public function setGrowingTipps($growing_tipps): self
  248.     {
  249.         $this->growing_tipps $growing_tipps;
  250.         return $this;
  251.     }
  252.     public function getCultivationCycles(): ?string
  253.     {
  254.         return $this->cultivation_cycles;
  255.     }
  256.     public function setCultivationCycles(?string $cultivation_cycles): self
  257.     {
  258.         $this->cultivation_cycles $cultivation_cycles;
  259.         return $this;
  260.     }
  261.     public function getGerminationDuration()
  262.     {
  263.         return $this->germination_duration;
  264.     }
  265.     public function setGerminationDuration($germination_duration): self
  266.     {
  267.         $this->germination_duration $germination_duration;
  268.         return $this;
  269.     }
  270.     public function getGrowthDuration()
  271.     {
  272.         return $this->growth_duration;
  273.     }
  274.     public function setGrowthDuration($growth_duration): self
  275.     {
  276.         $this->growth_duration $growth_duration;
  277.         return $this;
  278.     }
  279.     public function getGrowthSeason()
  280.     {
  281.         return $this->growth_season;
  282.     }
  283.     public function setGrowthSeason($growth_season): self
  284.     {
  285.         $this->growth_season $growth_season;
  286.         return $this;
  287.     }
  288.     public function getHarvestDuration()
  289.     {
  290.         return $this->harvest_duration;
  291.     }
  292.     public function setHarvestDuration($harvest_duration): self
  293.     {
  294.         $this->harvest_duration $harvest_duration;
  295.         return $this;
  296.     }
  297.     public function getHarvestSeason()
  298.     {
  299.         return $this->harvest_season;
  300.     }
  301.     public function setHarvestSeason($harvest_season): self
  302.     {
  303.         $this->harvest_season $harvest_season;
  304.         return $this;
  305.     }
  306.     public function getLightscore()
  307.     {
  308.         return $this->lightscore;
  309.     }
  310.     public function setLightscore($lightscore): self
  311.     {
  312.         $this->lightscore $lightscore;
  313.         return $this;
  314.     }
  315.     public function getGridLength(): ?int
  316.     {
  317.         return $this->grid_length;
  318.     }
  319.     public function setGridLength(?int $grid_length): self
  320.     {
  321.         $this->grid_length $grid_length;
  322.         return $this;
  323.     }
  324.     public function getGridWidth(): ?int
  325.     {
  326.         return $this->grid_width;
  327.     }
  328.     public function setGridWidth(?int $grid_width): self
  329.     {
  330.         $this->grid_width $grid_width;
  331.         return $this;
  332.     }
  333.     public function getHarvestAmount(): ?float
  334.     {
  335.         return $this->harvest_amount;
  336.     }
  337.     public function setHarvestAmount(?float $harvest_amount): self
  338.     {
  339.         $this->harvest_amount $harvest_amount;
  340.         return $this;
  341.     }
  342.     public function getNutrientDemand(): ?string
  343.     {
  344.         return $this->nutrient_demand;
  345.     }
  346.     public function setNutrientDemand(?string $nutrient_demand): self
  347.     {
  348.         $this->nutrient_demand $nutrient_demand;
  349.         return $this;
  350.     }
  351.     public function getLightingDemand(): ?string
  352.     {
  353.         return $this->lighting_demand;
  354.     }
  355.     public function setLightingDemand(?string $lighting_demand): self
  356.     {
  357.         $this->lighting_demand $lighting_demand;
  358.         return $this;
  359.     }
  360.     public function getSpread(): ?string
  361.     {
  362.         return $this->spread;
  363.     }
  364.     public function setSpread(?string $spread): self
  365.     {
  366.         $this->spread $spread;
  367.         return $this;
  368.     }
  369.     public function getDateCreated(): ?\DateTimeInterface
  370.     {
  371.         return $this->date_created;
  372.     }
  373.     public function setDateCreated(\DateTimeInterface $date_created): self
  374.     {
  375.         $this->date_created $date_created;
  376.         return $this;
  377.     }
  378.     /**
  379.      * @return Collection|Patchfield[]
  380.      */
  381.     public function getPatchCrop(): Collection
  382.     {
  383.         return $this->patchCrop;
  384.     }
  385.     public function addPatchCrop(Patchfield $patchCrop): self
  386.     {
  387.         if (!$this->patchCrop->contains($patchCrop)) {
  388.             $this->patchCrop[] = $patchCrop;
  389.             $patchCrop->setCrop($this);
  390.         }
  391.         return $this;
  392.     }
  393.     public function removePatchCrop(Patchfield $patchCrop): self
  394.     {
  395.         if ($this->patchCrop->contains($patchCrop)) {
  396.             $this->patchCrop->removeElement($patchCrop);
  397.             // set the owning side to null (unless already changed)
  398.             if ($patchCrop->getCrop() === $this) {
  399.                 $patchCrop->setCrop(null);
  400.             }
  401.         }
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return Collection|CropPest[]
  406.      */
  407.     public function getCropPest(): Collection
  408.     {
  409.         return $this->cropPest;
  410.     }
  411.     public function addCropPest(CropPest $cropPest): self
  412.     {
  413.         if (!$this->cropPest->contains($cropPest)) {
  414.             $this->cropPest[] = $cropPest;
  415.             $cropPest->setCrop($this);
  416.         }
  417.         return $this;
  418.     }
  419.     public function removeCropPest(CropPest $cropPest): self
  420.     {
  421.         if ($this->cropPest->contains($cropPest)) {
  422.             $this->cropPest->removeElement($cropPest);
  423.             // set the owning side to null (unless already changed)
  424.             if ($cropPest->getCrop() === $this) {
  425.                 $cropPest->setCrop(null);
  426.             }
  427.         }
  428.         return $this;
  429.     }
  430.     /**
  431.      * @return Collection|CropDisease[]
  432.      */
  433.     public function getCropDisease(): Collection
  434.     {
  435.         return $this->cropDisease;
  436.     }
  437.     public function addCropDisease(CropDisease $cropDisease): self
  438.     {
  439.         if (!$this->cropDisease->contains($cropDisease)) {
  440.             $this->cropDisease[] = $cropDisease;
  441.             $cropDisease->setCrop($this);
  442.         }
  443.         return $this;
  444.     }
  445.     public function removeCropDisease(CropDisease $cropDisease): self
  446.     {
  447.         if ($this->cropDisease->contains($cropDisease)) {
  448.             $this->cropDisease->removeElement($cropDisease);
  449.             // set the owning side to null (unless already changed)
  450.             if ($cropDisease->getCrop() === $this) {
  451.                 $cropDisease->setCrop(null);
  452.             }
  453.         }
  454.         return $this;
  455.     }
  456.     /**
  457.      * @return Collection|Cropaction[]
  458.      */
  459.     public function getCropaction(): Collection
  460.     {
  461.         return $this->cropaction;
  462.     }
  463.     public function addCropaction(Cropaction $cropaction): self
  464.     {
  465.         if (!$this->cropaction->contains($cropaction)) {
  466.             $this->cropaction[] = $cropaction;
  467.             $cropaction->setCrop($this);
  468.         }
  469.         return $this;
  470.     }
  471.     public function removeCropaction(Cropaction $cropaction): self
  472.     {
  473.         if ($this->cropaction->contains($cropaction)) {
  474.             $this->cropaction->removeElement($cropaction);
  475.             // set the owning side to null (unless already changed)
  476.             if ($cropaction->getCrop() === $this) {
  477.                 $cropaction->setCrop(null);
  478.             }
  479.         }
  480.         return $this;
  481.     }
  482.     public function getCropcategory(): ?Cropcategory
  483.     {
  484.         return $this->cropcategory;
  485.     }
  486.     public function setCropcategory(?Cropcategory $cropcategory): self
  487.     {
  488.         $this->cropcategory $cropcategory;
  489.         return $this;
  490.     }
  491.     public function getCompatibility()
  492.     {
  493.         return $this->compatibility;
  494.     }
  495.     public function setCompatibility($compatibility): self
  496.     {
  497.         $this->compatibility $compatibility;
  498.         return $this;
  499.     }
  500.     /**
  501.      * @return Collection|PlanCrop[]
  502.      */
  503.     public function getPlanCrop(): Collection
  504.     {
  505.         return $this->planCrop;
  506.     }
  507.     public function addPlanCrop(PlanCrop $planCrop): self
  508.     {
  509.         if (!$this->planCrop->contains($planCrop)) {
  510.             $this->planCrop[] = $planCrop;
  511.             $planCrop->setCrop($this);
  512.         }
  513.         return $this;
  514.     }
  515.     public function removePlanCrop(PlanCrop $planCrop): self
  516.     {
  517.         if ($this->planCrop->contains($planCrop)) {
  518.             $this->planCrop->removeElement($planCrop);
  519.             // set the owning side to null (unless already changed)
  520.             if ($planCrop->getCrop() === $this) {
  521.                 $planCrop->setCrop(null);
  522.             }
  523.         }
  524.         return $this;
  525.     }
  526.     /**
  527.      * @return Collection|ShoparticleCrop[]
  528.      */
  529.     public function getShoparticleCrop(): Collection
  530.     {
  531.         return $this->shoparticleCrop;
  532.     }
  533.     public function addShoparticleCrop(ShoparticleCrop $shoparticleCrop): self
  534.     {
  535.         if (!$this->shoparticleCrop->contains($shoparticleCrop)) {
  536.             $this->shoparticleCrop[] = $shoparticleCrop;
  537.             $shoparticleCrop->setCrop($this);
  538.         }
  539.         return $this;
  540.     }
  541.     public function removeShoparticleCrop(ShoparticleCrop $shoparticleCrop): self
  542.     {
  543.         if ($this->shoparticleCrop->contains($shoparticleCrop)) {
  544.             $this->shoparticleCrop->removeElement($shoparticleCrop);
  545.             // set the owning side to null (unless already changed)
  546.             if ($shoparticleCrop->getCrop() === $this) {
  547.                 $shoparticleCrop->setCrop(null);
  548.             }
  549.         }
  550.         return $this;
  551.     }
  552.     public function getPlantInRows(): ?bool
  553.     {
  554.         return $this->plant_in_rows;
  555.     }
  556.     public function setPlantInRows(?bool $plant_in_rows): self
  557.     {
  558.         $this->plant_in_rows $plant_in_rows;
  559.         return $this;
  560.     }
  561.     public function getGerminationSeason()
  562.     {
  563.         return $this->germination_season;
  564.     }
  565.     public function setGerminationSeason($germination_season): self
  566.     {
  567.         $this->germination_season $germination_season;
  568.         return $this;
  569.     }
  570.     /**
  571.      * @return Collection|FavoriteCrop[]
  572.      */
  573.     public function getFavoriteCrop(): Collection
  574.     {
  575.         return $this->favoriteCrop;
  576.     }
  577.     public function addFavoriteCrop(FavoriteCrop $favoriteCrop): self
  578.     {
  579.         if (!$this->favoriteCrop->contains($favoriteCrop)) {
  580.             $this->favoriteCrop[] = $favoriteCrop;
  581.             $favoriteCrop->setCrop($this);
  582.         }
  583.         return $this;
  584.     }
  585.     public function removeFavoriteCrop(FavoriteCrop $favoriteCrop): self
  586.     {
  587.         if ($this->favoriteCrop->contains($favoriteCrop)) {
  588.             $this->favoriteCrop->removeElement($favoriteCrop);
  589.             // set the owning side to null (unless already changed)
  590.             if ($favoriteCrop->getCrop() === $this) {
  591.                 $favoriteCrop->setCrop(null);
  592.             }
  593.         }
  594.         return $this;
  595.     }
  596.     public function getWaterDemand(): ?string
  597.     {
  598.         return $this->water_demand;
  599.     }
  600.     public function setWaterDemand(?string $water_demand): self
  601.     {
  602.         $this->water_demand $water_demand;
  603.         return $this;
  604.     }
  605.     /**
  606.      * @return Collection|Crop[]
  607.      */
  608.     public function getChildCrop(): Collection
  609.     {
  610.         return $this->childCrop;
  611.     }
  612.     public function addChildCrop(Crop $childCrop): self
  613.     {
  614.         if (!$this->childCrop->contains($childCrop)) {
  615.             $this->childCrop[] = $childCrop;
  616.             $childCrop->setParentCrop($this);
  617.         }
  618.         return $this;
  619.     }
  620.     public function removeChildCrop(Crop $childCrop): self
  621.     {
  622.         if ($this->childCrop->contains($childCrop)) {
  623.             $this->childCrop->removeElement($childCrop);
  624.             // set the owning side to null (unless already changed)
  625.             if ($childCrop->getParentCrop() === $this) {
  626.                 $childCrop->setParentCrop(null);
  627.             }
  628.         }
  629.         return $this;
  630.     }
  631.     public function getParentCrop(): ?self
  632.     {
  633.         return $this->parentCrop;
  634.     }
  635.     public function setParentCrop(?self $parentCrop): self
  636.     {
  637.         $this->parentCrop $parentCrop;
  638.         return $this;
  639.     }
  640.     public function getFertilizerType(): ?string
  641.     {
  642.         return $this->fertilizer_type;
  643.     }
  644.     public function setFertilizerType(?string $fertilizer_type): self
  645.     {
  646.         $this->fertilizer_type $fertilizer_type;
  647.         return $this;
  648.     }
  649.     public function getPrecultivationDuration()
  650.     {
  651.         return $this->precultivation_duration;
  652.     }
  653.     public function setPrecultivationDuration($precultivation_duration): self
  654.     {
  655.         $this->precultivation_duration $precultivation_duration;
  656.         return $this;
  657.     }
  658.     public function getPrecultivationSeason()
  659.     {
  660.         return $this->precultivation_season;
  661.     }
  662.     public function setPrecultivationSeason($precultivation_season): self
  663.     {
  664.         $this->precultivation_season $precultivation_season;
  665.         return $this;
  666.     }
  667.     public function getShortDescription(bool $skipTranslation false): ?string
  668.     {
  669.         if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
  670.             return $this->short_description;
  671.         }
  672.         $translated $this->translate()->getShortDescription();
  673.         return !empty($translated) ? $translated $this->short_description;
  674.     }
  675.     public function setShortDescription(?string $short_description): self
  676.     {
  677.         $this->short_description $short_description;
  678.         return $this;
  679.     }
  680.     public function getHasPrecultivation(): ?bool
  681.     {
  682.         return $this->has_precultivation;
  683.     }
  684.     public function setHasPrecultivation(?bool $has_precultivation): self
  685.     {
  686.         $this->has_precultivation $has_precultivation;
  687.         return $this;
  688.     }
  689.     public function getF1Hybrid(): ?bool
  690.     {
  691.         return $this->f1_hybrid;
  692.     }
  693.     public function setF1Hybrid(?bool $f1_hybrid): self
  694.     {
  695.         $this->f1_hybrid $f1_hybrid;
  696.         return $this;
  697.     }
  698.     public function getUserCropSettings()
  699.     {
  700.         return $this->user_crop_settings;
  701.     }
  702.     public function setUserCropSettings($user_crop_settings): self
  703.     {
  704.         $this->user_crop_settings $user_crop_settings;
  705.         return $this;
  706.     }
  707.     public function getUser(): ?User
  708.     {
  709.         return $this->user;
  710.     }
  711.     public function setUser(?User $user): self
  712.     {
  713.         $this->user $user;
  714.         return $this;
  715.     }
  716.     /**
  717.      * @return Collection|CropSynonym[]
  718.      */
  719.     public function getCropSynonym(): Collection
  720.     {
  721.         return $this->cropSynonym;
  722.     }
  723.     public function addCropSynonym(CropSynonym $cropSynonym): self
  724.     {
  725.         if (!$this->cropSynonym->contains($cropSynonym)) {
  726.             $this->cropSynonym[] = $cropSynonym;
  727.             $cropSynonym->setCrop($this);
  728.         }
  729.         return $this;
  730.     }
  731.     public function removeCropSynonym(CropSynonym $cropSynonym): self
  732.     {
  733.         if ($this->cropSynonym->contains($cropSynonym)) {
  734.             $this->cropSynonym->removeElement($cropSynonym);
  735.             // set the owning side to null (unless already changed)
  736.             if ($cropSynonym->getCrop() === $this) {
  737.                 $cropSynonym->setCrop(null);
  738.             }
  739.         }
  740.         return $this;
  741.     }
  742.     public function getGroundType(): ?string
  743.     {
  744.         return $this->ground_type;
  745.     }
  746.     public function setGroundType(?string $ground_type): self
  747.     {
  748.         $this->ground_type $ground_type;
  749.         return $this;
  750.     }
  751.     public function getColdResistant(): ?bool
  752.     {
  753.         return $this->cold_resistant;
  754.     }
  755.     public function setColdResistant(?bool $cold_resistant): self
  756.     {
  757.         $this->cold_resistant $cold_resistant;
  758.         return $this;
  759.     }
  760.     public function getIsShared(): ?bool
  761.     {
  762.         return $this->is_shared;
  763.     }
  764.     public function setIsShared(?bool $is_shared): self
  765.     {
  766.         $this->is_shared $is_shared;
  767.         return $this;
  768.     }
  769.     public function getDateUpdated(): ?\DateTimeInterface
  770.     {
  771.         return $this->date_updated;
  772.     }
  773.     public function setDateUpdated(?\DateTimeInterface $date_updated): self
  774.     {
  775.         $this->date_updated $date_updated;
  776.         return $this;
  777.     }
  778.     public function getSeedingDepth(): ?array
  779.     {
  780.         return $this->seeding_depth;
  781.     }
  782.     public function setSeedingDepth(?array $seeding_depth): self
  783.     {
  784.         $this->seeding_depth $seeding_depth;
  785.         return $this;
  786.     }
  787.     public function getSeedingDistance(): ?array
  788.     {
  789.         return $this->seeding_distance;
  790.     }
  791.     public function setSeedingDistance(?array $seeding_distance): self
  792.     {
  793.         $this->seeding_distance $seeding_distance;
  794.         return $this;
  795.     }
  796.     public function getRowDistance(): ?array
  797.     {
  798.         return $this->row_distance;
  799.     }
  800.     public function setRowDistance(?array $row_distance): self
  801.     {
  802.         $this->row_distance $row_distance;
  803.         return $this;
  804.     }
  805.     public function getIsApproved(): ?bool
  806.     {
  807.         return $this->is_approved;
  808.     }
  809.     public function setIsApproved(?bool $is_approved): self
  810.     {
  811.         $this->is_approved $is_approved;
  812.         return $this;
  813.     }
  814.     /**
  815.      * @return Collection|CropEdit[]
  816.      */
  817.     public function getCropEdit(): Collection
  818.     {
  819.         return $this->cropEdit;
  820.     }
  821.     public function addCropEdit(CropEdit $cropEdit): self
  822.     {
  823.         if (!$this->cropEdit->contains($cropEdit)) {
  824.             $this->cropEdit[] = $cropEdit;
  825.             $cropEdit->setCrop($this);
  826.         }
  827.         return $this;
  828.     }
  829.     public function removeCropEdit(CropEdit $cropEdit): self
  830.     {
  831.         if ($this->cropEdit->removeElement($cropEdit)) {
  832.             // set the owning side to null (unless already changed)
  833.             if ($cropEdit->getCrop() === $this) {
  834.                 $cropEdit->setCrop(null);
  835.             }
  836.         }
  837.         return $this;
  838.     }
  839.     /**
  840.      * @return Collection|CropRating[]
  841.      */
  842.     public function getCropRating(): Collection
  843.     {
  844.         return $this->cropRating;
  845.     }
  846.     public function addCropRating(CropRating $cropRating): self
  847.     {
  848.         if (!$this->cropRating->contains($cropRating)) {
  849.             $this->cropRating[] = $cropRating;
  850.             $cropRating->setCrop($this);
  851.         }
  852.         return $this;
  853.     }
  854.     public function removeCropRating(CropRating $cropRating): self
  855.     {
  856.         if ($this->cropRating->removeElement($cropRating)) {
  857.             // set the owning side to null (unless already changed)
  858.             if ($cropRating->getCrop() === $this) {
  859.                 $cropRating->setCrop(null);
  860.             }
  861.         }
  862.         return $this;
  863.     }
  864.     public function getPlantfamily(): ?Plantfamily
  865.     {
  866.         return $this->plantfamily;
  867.     }
  868.     public function setPlantfamily(?Plantfamily $plantfamily): self
  869.     {
  870.         $this->plantfamily $plantfamily;
  871.         return $this;
  872.     }
  873.     public function getPopularity(): ?int
  874.     {
  875.         return $this->popularity;
  876.     }
  877.     public function setPopularity(?int $popularity): self
  878.     {
  879.         $this->popularity $popularity;
  880.         return $this;
  881.     }
  882.     public function getSeasons(): ?array
  883.     {
  884.         return $this->seasons;
  885.     }
  886.     public function setSeasons(?array $seasons): self
  887.     {
  888.         $this->seasons $seasons;
  889.         return $this;
  890.     }
  891.     public function calculateSeasons(): void
  892.     {
  893.         // season = pre / main / post
  894.         // preseason plants MUST start and MUST end in preseason
  895.         // mainseason plants CAN start in preseason and CAN end in postseason
  896.         // postseason plants MUST start in postseason and CAN end in preseason in the following year
  897.         // ---pre---- | ---main--- | ---post---
  898.         // --xxxx---- | ---------- | ---------- (pre)
  899.         // --xxxxxxxx | xxxxx----- | ---------- (main)
  900.         // --------xx | xxxxxxxxxx | xx-------- (main)
  901.         // ---------- | --xxxxxxx- | ---------- (main)
  902.         // ---------- | --xxxxxxxx | x--------- (main)
  903.         // ---------- | ---------- | -xxx------ (post)
  904.         // xx-------- | ---------- | -------xxx (post)
  905.         $coldResistant $this->cold_resistant;
  906.         $weekAfterIceSaints 20;
  907.         $weekPostSeasonStart 38;
  908.         if (!isset($this->precultivation_season['start'], $this->precultivation_season['end']) && !isset($this->germination_season['start'], $this->germination_season['end'])) {
  909.             return;
  910.         }
  911.         $startWeekIsPrecultivationStart $this->has_precultivation && isset($this->precultivation_season['start']);
  912.         $earliestStartWeek $startWeekIsPrecultivationStart $this->precultivation_season['start'] : $this->germination_season['start'];
  913.         $latestStartWeek $startWeekIsPrecultivationStart $this->precultivation_season['end'] : $this->germination_season['end'];
  914.         $growthDurationInWeeks $this->getGrowthDurationInWeeks(true);
  915.         if ($earliestStartWeek $latestStartWeek) {
  916.             $earliestStartWeek 0;
  917.             $latestStartWeek 52;
  918.         }
  919.         $seasons = [];
  920.         if ($coldResistant === true && $earliestStartWeek $growthDurationInWeeks <= $weekAfterIceSaints) {
  921.             // fits in pre season
  922.             $seasons[] = 'pre';
  923.         }
  924.         if ($latestStartWeek $growthDurationInWeeks >= $weekAfterIceSaints && $earliestStartWeek $weekPostSeasonStart) {
  925.             // fits in main season
  926.             $seasons[] = 'main';
  927.         }
  928.         if ($latestStartWeek >= $weekPostSeasonStart) {
  929.             // fits in post season
  930.             $seasons[] = 'post';
  931.         }
  932.         $this->setSeasons($seasons);
  933.     }
  934.     private function getGrowthDurationInWeeks($withoutHarvest false)
  935.     {
  936.         $germinationDuration $this->parseDuration($this->germination_duration);
  937.         $precultivationDuration $this->parseDuration($this->precultivation_duration);
  938.         $growthDuration $this->parseDuration($this->growth_duration);
  939.         $harvestDuration 0;
  940.         if (!$withoutHarvest) {
  941.             if ($this->harvest_duration === "continuous") {
  942.                 $harvestDuration 8;
  943.             } else {
  944.                 $harvestDuration =
  945.                     (is_numeric($this->harvest_duration)
  946.                         ? (float)$this->harvest_duration
  947.                         2);
  948.             }
  949.         }
  950.         return ceil(
  951.             $germinationDuration +
  952.             $precultivationDuration +
  953.             $growthDuration +
  954.             $harvestDuration
  955.         );
  956.     }
  957.     private function parseDuration($duration): float
  958.     {
  959.         $durationNumber 0;
  960.         if (isset($duration['default'])) {
  961.             $defaultValue $duration['default'];
  962.             $durationNumber = (float)str_replace(',''.'$defaultValue);
  963.         }
  964.         return $durationNumber;
  965.     }
  966.     /**
  967.      * @return Collection<int, CropProperty>
  968.      */
  969.     public function getCropProperties(): Collection
  970.     {
  971.         return $this->cropProperties;
  972.     }
  973.     public function addCropProperty(CropProperty $cropProperty): self
  974.     {
  975.         if (!$this->cropProperties->contains($cropProperty)) {
  976.             $this->cropProperties[] = $cropProperty;
  977.             $cropProperty->setCrop($this);
  978.         }
  979.         return $this;
  980.     }
  981.     public function removeCropProperty(CropProperty $cropProperty): self
  982.     {
  983.         if ($this->cropProperties->removeElement($cropProperty)) {
  984.             // set the owning side to null (unless already changed)
  985.             if ($cropProperty->getCrop() === $this) {
  986.                 $cropProperty->setCrop(null);
  987.             }
  988.         }
  989.         return $this;
  990.     }
  991.     public function getDynamicLink(): ?string
  992.     {
  993.         return $this->dynamic_link;
  994.     }
  995.     public function setDynamicLink(?string $dynamic_link): self
  996.     {
  997.         $this->dynamic_link $dynamic_link;
  998.         return $this;
  999.     }
  1000.     public function getCultivationBreak(): ?float
  1001.     {
  1002.         return $this->cultivation_break;
  1003.     }
  1004.     public function setCultivationBreak(?float $cultivation_break): static
  1005.     {
  1006.         $this->cultivation_break $cultivation_break;
  1007.         return $this;
  1008.     }
  1009.     public function getGerminationType(): ?string
  1010.     {
  1011.         return $this->germination_type;
  1012.     }
  1013.     public function setGerminationType(?string $germination_type): static
  1014.     {
  1015.         $this->germination_type $germination_type;
  1016.         return $this;
  1017.     }
  1018.     public function getGerminationTemperature(): ?string
  1019.     {
  1020.         return $this->germination_temperature;
  1021.     }
  1022.     public function setGerminationTemperature(?string $germination_temperature): static
  1023.     {
  1024.         $this->germination_temperature $germination_temperature;
  1025.         return $this;
  1026.     }
  1027.     public function getShopCategoryUrl(): ?string
  1028.     {
  1029.         return $this->shop_category_url;
  1030.     }
  1031.     public function setShopCategoryUrl(?string $shop_category_url): static
  1032.     {
  1033.         $this->shop_category_url $shop_category_url;
  1034.         return $this;
  1035.     }
  1036.     public function getGrowthHabit(): ?string
  1037.     {
  1038.         return $this->growth_habit;
  1039.     }
  1040.     public function setGrowthHabit(?string $growth_habit): static
  1041.     {
  1042.         $this->growth_habit $growth_habit;
  1043.         return $this;
  1044.     }
  1045.     /**
  1046.      * @return Collection<int, ShoparticleBlockentry>
  1047.      */
  1048.     public function getShoparticleBlockentries(): Collection
  1049.     {
  1050.         return $this->shoparticleBlockentries;
  1051.     }
  1052.     public function addShoparticleBlockentry(ShoparticleBlockentry $shoparticleBlockentry): static
  1053.     {
  1054.         if (!$this->shoparticleBlockentries->contains($shoparticleBlockentry)) {
  1055.             $this->shoparticleBlockentries->add($shoparticleBlockentry);
  1056.             $shoparticleBlockentry->setCrop($this);
  1057.         }
  1058.         return $this;
  1059.     }
  1060.     public function removeShoparticleBlockentry(ShoparticleBlockentry $shoparticleBlockentry): static
  1061.     {
  1062.         if ($this->shoparticleBlockentries->removeElement($shoparticleBlockentry)) {
  1063.             // set the owning side to null (unless already changed)
  1064.             if ($shoparticleBlockentry->getCrop() === $this) {
  1065.                 $shoparticleBlockentry->setCrop(null);
  1066.             }
  1067.         }
  1068.         return $this;
  1069.     }
  1070.     public function getIsGreenManure(): ?bool
  1071.     {
  1072.         return $this->isGreenManure;
  1073.     }
  1074.     public function setIsGreenManure(?bool $isGreenManure): static
  1075.     {
  1076.         $this->isGreenManure $isGreenManure;
  1077.         return $this;
  1078.     }
  1079.     /**
  1080.      * @return Collection<int, CropImage>
  1081.      */
  1082.     public function getCropImages(): Collection
  1083.     {
  1084.         return $this->cropImages;
  1085.     }
  1086.     public function addCropImage(CropImage $cropImage): static
  1087.     {
  1088.         if (!$this->cropImages->contains($cropImage)) {
  1089.             $this->cropImages->add($cropImage);
  1090.             $cropImage->setCrop($this);
  1091.         }
  1092.         return $this;
  1093.     }
  1094.     public function removeCropImage(CropImage $cropImage): static
  1095.     {
  1096.         if ($this->cropImages->removeElement($cropImage)) {
  1097.             // set the owning side to null (unless already changed)
  1098.             if ($cropImage->getCrop() === $this) {
  1099.                 $cropImage->setCrop(null);
  1100.             }
  1101.         }
  1102.         return $this;
  1103.     }
  1104.     public function getClimatezone(): ?Climatezone
  1105.     {
  1106.         return $this->climatezone;
  1107.     }
  1108.     public function setClimatezone(?Climatezone $climatezone): static
  1109.     {
  1110.         $this->climatezone $climatezone;
  1111.         return $this;
  1112.     }
  1113.     public function getGtinBarcode(): ?string
  1114.     {
  1115.         return $this->gtin_barcode;
  1116.     }
  1117.     public function setGtinBarcode(?string $gtin_barcode): static
  1118.     {
  1119.         $this->gtin_barcode $gtin_barcode;
  1120.         return $this;
  1121.     }
  1122. }