<?php
namespace App\Entity;
use App\Translation\AutoTranslatableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
#[ORM\Table(name: 'crop')]
#[ORM\Index(name: 'IX_identifier', columns: ['identifier'])]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\CropRepository')]
class Crop implements TranslatableInterface
{
use AutoTranslatableTrait;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'string', nullable: true)]
private $identifier;
#[ORM\Column(type: 'string', nullable: true)]
private $name;
#[ORM\Column(type: 'string', nullable: true)]
private $latin_name;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(type: 'text', nullable: true)]
private $short_description;
#[ORM\Column(type: 'string', nullable: true)]
private $origin;
#[ORM\Column(type: 'json', nullable: true)]
private $growing_tipps;
#[ORM\Column(type: 'string', nullable: true)]
private $cultivation_cycles;
#[ORM\Column(type: 'json', nullable: true)]
private $germination_duration;
#[ORM\Column(type: 'json', nullable: true)]
private $germination_season;
#[ORM\Column(type: 'json', nullable: true)]
private $precultivation_duration;
#[ORM\Column(type: 'json', nullable: true)]
private $precultivation_season;
#[ORM\Column(type: 'boolean', nullable: true)]
private $has_precultivation;
#[ORM\Column(type: 'json', nullable: true)]
private $growth_duration;
#[ORM\Column(type: 'json', nullable: true)]
private $growth_season;
#[ORM\Column(type: 'json', nullable: true)]
private $harvest_duration;
#[ORM\Column(type: 'json', nullable: true)]
private $harvest_season;
#[ORM\Column(type: 'json', nullable: true)]
private $lightscore;
#[ORM\Column(type: 'integer', nullable: true)]
private $grid_length;
#[ORM\Column(type: 'integer', nullable: true)]
private $grid_width;
#[ORM\Column(type: 'float', nullable: true)]
private $harvest_amount;
#[ORM\Column(type: 'string', nullable: true)]
private $nutrient_demand;
#[ORM\Column(type: 'string', nullable: true)]
private $lighting_demand;
#[ORM\Column(type: 'string', nullable: true)]
private $water_demand;
#[ORM\Column(type: 'json', nullable: true)]
private $seeding_depth;
#[ORM\Column(type: 'json', nullable: true)]
private $seeding_distance;
#[ORM\Column(type: 'string', nullable: true)]
private $spread;
#[ORM\Column(type: 'json', nullable: true)]
private $compatibility;
#[ORM\Column(type: 'boolean', nullable: true)]
private $plant_in_rows;
#[ORM\Column(type: 'boolean', nullable: true)]
private $f1_hybrid;
#[ORM\Column(type: 'json', nullable: true)]
private $row_distance;
#[ORM\Column(type: 'string', nullable: true)]
private $fertilizer_type;
#[ORM\Column(type: 'json', nullable: true)]
private $user_crop_settings;
#[ORM\Column(type: 'string', nullable: true)]
private $ground_type;
#[ORM\Column(type: 'boolean', nullable: true)]
private $cold_resistant;
#[ORM\Column(type: 'boolean', nullable: true)]
private $is_shared;
#[ORM\Column(type: 'boolean', nullable: true)]
private $is_approved;
#[ORM\Column(type: 'datetime', nullable: false)]
private $date_created;
#[ORM\Column(type: 'datetime', nullable: true)]
private $date_updated;
#[ORM\OneToMany(targetEntity: 'App\Entity\Crop', mappedBy: 'parentCrop')]
private $childCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\Patchfield', mappedBy: 'crop')]
private $patchCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropPest', mappedBy: 'crop')]
private $cropPest;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropDisease', mappedBy: 'crop')]
private $cropDisease;
#[ORM\OneToMany(targetEntity: 'App\Entity\Cropaction', mappedBy: 'crop')]
private $cropaction;
#[ORM\OneToMany(targetEntity: 'App\Entity\PlanCrop', mappedBy: 'crop')]
private $planCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\ShoparticleCrop', mappedBy: 'crop')]
private $shoparticleCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\FavoriteCrop', mappedBy: 'crop')]
private $favoriteCrop;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropSynonym', mappedBy: 'crop')]
private $cropSynonym;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropEdit', mappedBy: 'crop')]
private $cropEdit;
#[ORM\OneToMany(targetEntity: 'App\Entity\CropRating', mappedBy: 'crop')]
private $cropRating;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Cropcategory', inversedBy: 'crop')]
#[ORM\JoinColumn(name: 'cropcategory_id', referencedColumnName: 'id')]
private $cropcategory;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Crop', inversedBy: 'childCrop')]
#[ORM\JoinColumn(name: 'parent_crop_id', referencedColumnName: 'id')]
private $parentCrop;
#[ORM\ManyToOne(targetEntity: 'App\Entity\User', inversedBy: 'crop')]
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
private $user;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Plantfamily', inversedBy: 'crop')]
#[ORM\JoinColumn(name: 'plantfamily_id', referencedColumnName: 'id')]
private $plantfamily;
#[ORM\Column(type: 'integer', nullable: true)]
private $popularity;
#[ORM\Column(type: 'json', nullable: true)]
private $seasons = [];
#[ORM\OneToMany(targetEntity: CropProperty::class, mappedBy: 'crop', orphanRemoval: true)]
private $cropProperties;
#[ORM\OneToMany(targetEntity: CropTranslation::class, mappedBy: 'translatable', orphanRemoval: true)]
private $cropTranslation;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $dynamic_link;
#[ORM\Column(nullable: true)]
private ?float $cultivation_break = null;
#[ORM\Column(length: 10, nullable: true)]
private ?string $germination_type = null;
#[ORM\Column(length: 10, nullable: true)]
private ?string $germination_temperature = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $shop_category_url = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $growth_habit = null;
#[ORM\OneToMany(mappedBy: 'crop', targetEntity: ShoparticleBlockentry::class, orphanRemoval: true)]
private Collection $shoparticleBlockentries;
#[ORM\Column(nullable: true)]
private ?bool $isGreenManure = null;
#[ORM\OneToMany(mappedBy: 'crop', targetEntity: CropImage::class, orphanRemoval: true)]
private Collection $cropImages;
#[ORM\ManyToOne]
private ?Climatezone $climatezone = null;
#[ORM\Column(type: Types::BIGINT, nullable: true)]
private ?string $gtin_barcode = null;
public function __construct()
{
$this->patchCrop = new ArrayCollection();
$this->cropPest = new ArrayCollection();
$this->cropDisease = new ArrayCollection();
$this->cropaction = new ArrayCollection();
$this->planCrop = new ArrayCollection();
$this->shoparticleCrop = new ArrayCollection();
$this->favoriteCrop = new ArrayCollection();
$this->childCrop = new ArrayCollection();
$this->cropSynonym = new ArrayCollection();
$this->cropEdit = new ArrayCollection();
$this->cropRating = new ArrayCollection();
$this->cropProperties = new ArrayCollection();
$this->shoparticleBlockentries = new ArrayCollection();
$this->cropImages = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdentifier(): ?string
{
return $this->identifier;
}
public function setIdentifier(?string $identifier): self
{
$this->identifier = $identifier;
return $this;
}
public function getName(bool $skipTranslation = false): ?string
{
if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->name;
}
$translated = $this->translate()->getName();
return !empty($translated) ? $translated : $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getLatinName(): ?string
{
return $this->latin_name;
}
public function setLatinName(?string $latin_name): self
{
$this->latin_name = $latin_name;
return $this;
}
public function getDescription(bool $skipTranslation = false): ?string
{
if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->description;
}
$translated = $this->translate()->getDescription();
return !empty($translated) ? $translated : $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getOrigin(bool $skipTranslation = false): ?string
{
if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->origin;
}
$translated = $this->translate()->getOrigin();
return !empty($translated) ? $translated : $this->origin;
}
public function setOrigin(?string $origin): self
{
$this->origin = $origin;
return $this;
}
public function getGrowingTipps(bool $skipTranslation = false)
{
if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->growing_tipps;
}
$translated = $this->translate()->getGrowingTipps();
return !empty($translated) ? $translated : $this->growing_tipps;
}
public function setGrowingTipps($growing_tipps): self
{
$this->growing_tipps = $growing_tipps;
return $this;
}
public function getCultivationCycles(): ?string
{
return $this->cultivation_cycles;
}
public function setCultivationCycles(?string $cultivation_cycles): self
{
$this->cultivation_cycles = $cultivation_cycles;
return $this;
}
public function getGerminationDuration()
{
return $this->germination_duration;
}
public function setGerminationDuration($germination_duration): self
{
$this->germination_duration = $germination_duration;
return $this;
}
public function getGrowthDuration()
{
return $this->growth_duration;
}
public function setGrowthDuration($growth_duration): self
{
$this->growth_duration = $growth_duration;
return $this;
}
public function getGrowthSeason()
{
return $this->growth_season;
}
public function setGrowthSeason($growth_season): self
{
$this->growth_season = $growth_season;
return $this;
}
public function getHarvestDuration()
{
return $this->harvest_duration;
}
public function setHarvestDuration($harvest_duration): self
{
$this->harvest_duration = $harvest_duration;
return $this;
}
public function getHarvestSeason()
{
return $this->harvest_season;
}
public function setHarvestSeason($harvest_season): self
{
$this->harvest_season = $harvest_season;
return $this;
}
public function getLightscore()
{
return $this->lightscore;
}
public function setLightscore($lightscore): self
{
$this->lightscore = $lightscore;
return $this;
}
public function getGridLength(): ?int
{
return $this->grid_length;
}
public function setGridLength(?int $grid_length): self
{
$this->grid_length = $grid_length;
return $this;
}
public function getGridWidth(): ?int
{
return $this->grid_width;
}
public function setGridWidth(?int $grid_width): self
{
$this->grid_width = $grid_width;
return $this;
}
public function getHarvestAmount(): ?float
{
return $this->harvest_amount;
}
public function setHarvestAmount(?float $harvest_amount): self
{
$this->harvest_amount = $harvest_amount;
return $this;
}
public function getNutrientDemand(): ?string
{
return $this->nutrient_demand;
}
public function setNutrientDemand(?string $nutrient_demand): self
{
$this->nutrient_demand = $nutrient_demand;
return $this;
}
public function getLightingDemand(): ?string
{
return $this->lighting_demand;
}
public function setLightingDemand(?string $lighting_demand): self
{
$this->lighting_demand = $lighting_demand;
return $this;
}
public function getSpread(): ?string
{
return $this->spread;
}
public function setSpread(?string $spread): self
{
$this->spread = $spread;
return $this;
}
public function getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
/**
* @return Collection|Patchfield[]
*/
public function getPatchCrop(): Collection
{
return $this->patchCrop;
}
public function addPatchCrop(Patchfield $patchCrop): self
{
if (!$this->patchCrop->contains($patchCrop)) {
$this->patchCrop[] = $patchCrop;
$patchCrop->setCrop($this);
}
return $this;
}
public function removePatchCrop(Patchfield $patchCrop): self
{
if ($this->patchCrop->contains($patchCrop)) {
$this->patchCrop->removeElement($patchCrop);
// set the owning side to null (unless already changed)
if ($patchCrop->getCrop() === $this) {
$patchCrop->setCrop(null);
}
}
return $this;
}
/**
* @return Collection|CropPest[]
*/
public function getCropPest(): Collection
{
return $this->cropPest;
}
public function addCropPest(CropPest $cropPest): self
{
if (!$this->cropPest->contains($cropPest)) {
$this->cropPest[] = $cropPest;
$cropPest->setCrop($this);
}
return $this;
}
public function removeCropPest(CropPest $cropPest): self
{
if ($this->cropPest->contains($cropPest)) {
$this->cropPest->removeElement($cropPest);
// set the owning side to null (unless already changed)
if ($cropPest->getCrop() === $this) {
$cropPest->setCrop(null);
}
}
return $this;
}
/**
* @return Collection|CropDisease[]
*/
public function getCropDisease(): Collection
{
return $this->cropDisease;
}
public function addCropDisease(CropDisease $cropDisease): self
{
if (!$this->cropDisease->contains($cropDisease)) {
$this->cropDisease[] = $cropDisease;
$cropDisease->setCrop($this);
}
return $this;
}
public function removeCropDisease(CropDisease $cropDisease): self
{
if ($this->cropDisease->contains($cropDisease)) {
$this->cropDisease->removeElement($cropDisease);
// set the owning side to null (unless already changed)
if ($cropDisease->getCrop() === $this) {
$cropDisease->setCrop(null);
}
}
return $this;
}
/**
* @return Collection|Cropaction[]
*/
public function getCropaction(): Collection
{
return $this->cropaction;
}
public function addCropaction(Cropaction $cropaction): self
{
if (!$this->cropaction->contains($cropaction)) {
$this->cropaction[] = $cropaction;
$cropaction->setCrop($this);
}
return $this;
}
public function removeCropaction(Cropaction $cropaction): self
{
if ($this->cropaction->contains($cropaction)) {
$this->cropaction->removeElement($cropaction);
// set the owning side to null (unless already changed)
if ($cropaction->getCrop() === $this) {
$cropaction->setCrop(null);
}
}
return $this;
}
public function getCropcategory(): ?Cropcategory
{
return $this->cropcategory;
}
public function setCropcategory(?Cropcategory $cropcategory): self
{
$this->cropcategory = $cropcategory;
return $this;
}
public function getCompatibility()
{
return $this->compatibility;
}
public function setCompatibility($compatibility): self
{
$this->compatibility = $compatibility;
return $this;
}
/**
* @return Collection|PlanCrop[]
*/
public function getPlanCrop(): Collection
{
return $this->planCrop;
}
public function addPlanCrop(PlanCrop $planCrop): self
{
if (!$this->planCrop->contains($planCrop)) {
$this->planCrop[] = $planCrop;
$planCrop->setCrop($this);
}
return $this;
}
public function removePlanCrop(PlanCrop $planCrop): self
{
if ($this->planCrop->contains($planCrop)) {
$this->planCrop->removeElement($planCrop);
// set the owning side to null (unless already changed)
if ($planCrop->getCrop() === $this) {
$planCrop->setCrop(null);
}
}
return $this;
}
/**
* @return Collection|ShoparticleCrop[]
*/
public function getShoparticleCrop(): Collection
{
return $this->shoparticleCrop;
}
public function addShoparticleCrop(ShoparticleCrop $shoparticleCrop): self
{
if (!$this->shoparticleCrop->contains($shoparticleCrop)) {
$this->shoparticleCrop[] = $shoparticleCrop;
$shoparticleCrop->setCrop($this);
}
return $this;
}
public function removeShoparticleCrop(ShoparticleCrop $shoparticleCrop): self
{
if ($this->shoparticleCrop->contains($shoparticleCrop)) {
$this->shoparticleCrop->removeElement($shoparticleCrop);
// set the owning side to null (unless already changed)
if ($shoparticleCrop->getCrop() === $this) {
$shoparticleCrop->setCrop(null);
}
}
return $this;
}
public function getPlantInRows(): ?bool
{
return $this->plant_in_rows;
}
public function setPlantInRows(?bool $plant_in_rows): self
{
$this->plant_in_rows = $plant_in_rows;
return $this;
}
public function getGerminationSeason()
{
return $this->germination_season;
}
public function setGerminationSeason($germination_season): self
{
$this->germination_season = $germination_season;
return $this;
}
/**
* @return Collection|FavoriteCrop[]
*/
public function getFavoriteCrop(): Collection
{
return $this->favoriteCrop;
}
public function addFavoriteCrop(FavoriteCrop $favoriteCrop): self
{
if (!$this->favoriteCrop->contains($favoriteCrop)) {
$this->favoriteCrop[] = $favoriteCrop;
$favoriteCrop->setCrop($this);
}
return $this;
}
public function removeFavoriteCrop(FavoriteCrop $favoriteCrop): self
{
if ($this->favoriteCrop->contains($favoriteCrop)) {
$this->favoriteCrop->removeElement($favoriteCrop);
// set the owning side to null (unless already changed)
if ($favoriteCrop->getCrop() === $this) {
$favoriteCrop->setCrop(null);
}
}
return $this;
}
public function getWaterDemand(): ?string
{
return $this->water_demand;
}
public function setWaterDemand(?string $water_demand): self
{
$this->water_demand = $water_demand;
return $this;
}
/**
* @return Collection|Crop[]
*/
public function getChildCrop(): Collection
{
return $this->childCrop;
}
public function addChildCrop(Crop $childCrop): self
{
if (!$this->childCrop->contains($childCrop)) {
$this->childCrop[] = $childCrop;
$childCrop->setParentCrop($this);
}
return $this;
}
public function removeChildCrop(Crop $childCrop): self
{
if ($this->childCrop->contains($childCrop)) {
$this->childCrop->removeElement($childCrop);
// set the owning side to null (unless already changed)
if ($childCrop->getParentCrop() === $this) {
$childCrop->setParentCrop(null);
}
}
return $this;
}
public function getParentCrop(): ?self
{
return $this->parentCrop;
}
public function setParentCrop(?self $parentCrop): self
{
$this->parentCrop = $parentCrop;
return $this;
}
public function getFertilizerType(): ?string
{
return $this->fertilizer_type;
}
public function setFertilizerType(?string $fertilizer_type): self
{
$this->fertilizer_type = $fertilizer_type;
return $this;
}
public function getPrecultivationDuration()
{
return $this->precultivation_duration;
}
public function setPrecultivationDuration($precultivation_duration): self
{
$this->precultivation_duration = $precultivation_duration;
return $this;
}
public function getPrecultivationSeason()
{
return $this->precultivation_season;
}
public function setPrecultivationSeason($precultivation_season): self
{
$this->precultivation_season = $precultivation_season;
return $this;
}
public function getShortDescription(bool $skipTranslation = false): ?string
{
if ($skipTranslation || $this->getCurrentLocale() === $this->getDefaultLocale()) {
return $this->short_description;
}
$translated = $this->translate()->getShortDescription();
return !empty($translated) ? $translated : $this->short_description;
}
public function setShortDescription(?string $short_description): self
{
$this->short_description = $short_description;
return $this;
}
public function getHasPrecultivation(): ?bool
{
return $this->has_precultivation;
}
public function setHasPrecultivation(?bool $has_precultivation): self
{
$this->has_precultivation = $has_precultivation;
return $this;
}
public function getF1Hybrid(): ?bool
{
return $this->f1_hybrid;
}
public function setF1Hybrid(?bool $f1_hybrid): self
{
$this->f1_hybrid = $f1_hybrid;
return $this;
}
public function getUserCropSettings()
{
return $this->user_crop_settings;
}
public function setUserCropSettings($user_crop_settings): self
{
$this->user_crop_settings = $user_crop_settings;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection|CropSynonym[]
*/
public function getCropSynonym(): Collection
{
return $this->cropSynonym;
}
public function addCropSynonym(CropSynonym $cropSynonym): self
{
if (!$this->cropSynonym->contains($cropSynonym)) {
$this->cropSynonym[] = $cropSynonym;
$cropSynonym->setCrop($this);
}
return $this;
}
public function removeCropSynonym(CropSynonym $cropSynonym): self
{
if ($this->cropSynonym->contains($cropSynonym)) {
$this->cropSynonym->removeElement($cropSynonym);
// set the owning side to null (unless already changed)
if ($cropSynonym->getCrop() === $this) {
$cropSynonym->setCrop(null);
}
}
return $this;
}
public function getGroundType(): ?string
{
return $this->ground_type;
}
public function setGroundType(?string $ground_type): self
{
$this->ground_type = $ground_type;
return $this;
}
public function getColdResistant(): ?bool
{
return $this->cold_resistant;
}
public function setColdResistant(?bool $cold_resistant): self
{
$this->cold_resistant = $cold_resistant;
return $this;
}
public function getIsShared(): ?bool
{
return $this->is_shared;
}
public function setIsShared(?bool $is_shared): self
{
$this->is_shared = $is_shared;
return $this;
}
public function getDateUpdated(): ?\DateTimeInterface
{
return $this->date_updated;
}
public function setDateUpdated(?\DateTimeInterface $date_updated): self
{
$this->date_updated = $date_updated;
return $this;
}
public function getSeedingDepth(): ?array
{
return $this->seeding_depth;
}
public function setSeedingDepth(?array $seeding_depth): self
{
$this->seeding_depth = $seeding_depth;
return $this;
}
public function getSeedingDistance(): ?array
{
return $this->seeding_distance;
}
public function setSeedingDistance(?array $seeding_distance): self
{
$this->seeding_distance = $seeding_distance;
return $this;
}
public function getRowDistance(): ?array
{
return $this->row_distance;
}
public function setRowDistance(?array $row_distance): self
{
$this->row_distance = $row_distance;
return $this;
}
public function getIsApproved(): ?bool
{
return $this->is_approved;
}
public function setIsApproved(?bool $is_approved): self
{
$this->is_approved = $is_approved;
return $this;
}
/**
* @return Collection|CropEdit[]
*/
public function getCropEdit(): Collection
{
return $this->cropEdit;
}
public function addCropEdit(CropEdit $cropEdit): self
{
if (!$this->cropEdit->contains($cropEdit)) {
$this->cropEdit[] = $cropEdit;
$cropEdit->setCrop($this);
}
return $this;
}
public function removeCropEdit(CropEdit $cropEdit): self
{
if ($this->cropEdit->removeElement($cropEdit)) {
// set the owning side to null (unless already changed)
if ($cropEdit->getCrop() === $this) {
$cropEdit->setCrop(null);
}
}
return $this;
}
/**
* @return Collection|CropRating[]
*/
public function getCropRating(): Collection
{
return $this->cropRating;
}
public function addCropRating(CropRating $cropRating): self
{
if (!$this->cropRating->contains($cropRating)) {
$this->cropRating[] = $cropRating;
$cropRating->setCrop($this);
}
return $this;
}
public function removeCropRating(CropRating $cropRating): self
{
if ($this->cropRating->removeElement($cropRating)) {
// set the owning side to null (unless already changed)
if ($cropRating->getCrop() === $this) {
$cropRating->setCrop(null);
}
}
return $this;
}
public function getPlantfamily(): ?Plantfamily
{
return $this->plantfamily;
}
public function setPlantfamily(?Plantfamily $plantfamily): self
{
$this->plantfamily = $plantfamily;
return $this;
}
public function getPopularity(): ?int
{
return $this->popularity;
}
public function setPopularity(?int $popularity): self
{
$this->popularity = $popularity;
return $this;
}
public function getSeasons(): ?array
{
return $this->seasons;
}
public function setSeasons(?array $seasons): self
{
$this->seasons = $seasons;
return $this;
}
public function calculateSeasons(): void
{
// season = pre / main / post
// preseason plants MUST start and MUST end in preseason
// mainseason plants CAN start in preseason and CAN end in postseason
// postseason plants MUST start in postseason and CAN end in preseason in the following year
// ---pre---- | ---main--- | ---post---
// --xxxx---- | ---------- | ---------- (pre)
// --xxxxxxxx | xxxxx----- | ---------- (main)
// --------xx | xxxxxxxxxx | xx-------- (main)
// ---------- | --xxxxxxx- | ---------- (main)
// ---------- | --xxxxxxxx | x--------- (main)
// ---------- | ---------- | -xxx------ (post)
// xx-------- | ---------- | -------xxx (post)
$coldResistant = $this->cold_resistant;
$weekAfterIceSaints = 20;
$weekPostSeasonStart = 38;
if (!isset($this->precultivation_season['start'], $this->precultivation_season['end']) && !isset($this->germination_season['start'], $this->germination_season['end'])) {
return;
}
$startWeekIsPrecultivationStart = $this->has_precultivation && isset($this->precultivation_season['start']);
$earliestStartWeek = $startWeekIsPrecultivationStart ? $this->precultivation_season['start'] : $this->germination_season['start'];
$latestStartWeek = $startWeekIsPrecultivationStart ? $this->precultivation_season['end'] : $this->germination_season['end'];
$growthDurationInWeeks = $this->getGrowthDurationInWeeks(true);
if ($earliestStartWeek > $latestStartWeek) {
$earliestStartWeek = 0;
$latestStartWeek = 52;
}
$seasons = [];
if ($coldResistant === true && $earliestStartWeek + $growthDurationInWeeks <= $weekAfterIceSaints) {
// fits in pre season
$seasons[] = 'pre';
}
if ($latestStartWeek + $growthDurationInWeeks >= $weekAfterIceSaints && $earliestStartWeek < $weekPostSeasonStart) {
// fits in main season
$seasons[] = 'main';
}
if ($latestStartWeek >= $weekPostSeasonStart) {
// fits in post season
$seasons[] = 'post';
}
$this->setSeasons($seasons);
}
private function getGrowthDurationInWeeks($withoutHarvest = false)
{
$germinationDuration = $this->parseDuration($this->germination_duration);
$precultivationDuration = $this->parseDuration($this->precultivation_duration);
$growthDuration = $this->parseDuration($this->growth_duration);
$harvestDuration = 0;
if (!$withoutHarvest) {
if ($this->harvest_duration === "continuous") {
$harvestDuration = 8;
} else {
$harvestDuration =
(is_numeric($this->harvest_duration)
? (float)$this->harvest_duration
: 2);
}
}
return ceil(
$germinationDuration +
$precultivationDuration +
$growthDuration +
$harvestDuration
);
}
private function parseDuration($duration): float
{
$durationNumber = 0;
if (isset($duration['default'])) {
$defaultValue = $duration['default'];
$durationNumber = (float)str_replace(',', '.', $defaultValue);
}
return $durationNumber;
}
/**
* @return Collection<int, CropProperty>
*/
public function getCropProperties(): Collection
{
return $this->cropProperties;
}
public function addCropProperty(CropProperty $cropProperty): self
{
if (!$this->cropProperties->contains($cropProperty)) {
$this->cropProperties[] = $cropProperty;
$cropProperty->setCrop($this);
}
return $this;
}
public function removeCropProperty(CropProperty $cropProperty): self
{
if ($this->cropProperties->removeElement($cropProperty)) {
// set the owning side to null (unless already changed)
if ($cropProperty->getCrop() === $this) {
$cropProperty->setCrop(null);
}
}
return $this;
}
public function getDynamicLink(): ?string
{
return $this->dynamic_link;
}
public function setDynamicLink(?string $dynamic_link): self
{
$this->dynamic_link = $dynamic_link;
return $this;
}
public function getCultivationBreak(): ?float
{
return $this->cultivation_break;
}
public function setCultivationBreak(?float $cultivation_break): static
{
$this->cultivation_break = $cultivation_break;
return $this;
}
public function getGerminationType(): ?string
{
return $this->germination_type;
}
public function setGerminationType(?string $germination_type): static
{
$this->germination_type = $germination_type;
return $this;
}
public function getGerminationTemperature(): ?string
{
return $this->germination_temperature;
}
public function setGerminationTemperature(?string $germination_temperature): static
{
$this->germination_temperature = $germination_temperature;
return $this;
}
public function getShopCategoryUrl(): ?string
{
return $this->shop_category_url;
}
public function setShopCategoryUrl(?string $shop_category_url): static
{
$this->shop_category_url = $shop_category_url;
return $this;
}
public function getGrowthHabit(): ?string
{
return $this->growth_habit;
}
public function setGrowthHabit(?string $growth_habit): static
{
$this->growth_habit = $growth_habit;
return $this;
}
/**
* @return Collection<int, ShoparticleBlockentry>
*/
public function getShoparticleBlockentries(): Collection
{
return $this->shoparticleBlockentries;
}
public function addShoparticleBlockentry(ShoparticleBlockentry $shoparticleBlockentry): static
{
if (!$this->shoparticleBlockentries->contains($shoparticleBlockentry)) {
$this->shoparticleBlockentries->add($shoparticleBlockentry);
$shoparticleBlockentry->setCrop($this);
}
return $this;
}
public function removeShoparticleBlockentry(ShoparticleBlockentry $shoparticleBlockentry): static
{
if ($this->shoparticleBlockentries->removeElement($shoparticleBlockentry)) {
// set the owning side to null (unless already changed)
if ($shoparticleBlockentry->getCrop() === $this) {
$shoparticleBlockentry->setCrop(null);
}
}
return $this;
}
public function getIsGreenManure(): ?bool
{
return $this->isGreenManure;
}
public function setIsGreenManure(?bool $isGreenManure): static
{
$this->isGreenManure = $isGreenManure;
return $this;
}
/**
* @return Collection<int, CropImage>
*/
public function getCropImages(): Collection
{
return $this->cropImages;
}
public function addCropImage(CropImage $cropImage): static
{
if (!$this->cropImages->contains($cropImage)) {
$this->cropImages->add($cropImage);
$cropImage->setCrop($this);
}
return $this;
}
public function removeCropImage(CropImage $cropImage): static
{
if ($this->cropImages->removeElement($cropImage)) {
// set the owning side to null (unless already changed)
if ($cropImage->getCrop() === $this) {
$cropImage->setCrop(null);
}
}
return $this;
}
public function getClimatezone(): ?Climatezone
{
return $this->climatezone;
}
public function setClimatezone(?Climatezone $climatezone): static
{
$this->climatezone = $climatezone;
return $this;
}
public function getGtinBarcode(): ?string
{
return $this->gtin_barcode;
}
public function setGtinBarcode(?string $gtin_barcode): static
{
$this->gtin_barcode = $gtin_barcode;
return $this;
}
}