<?php
namespace App\Entity;
use App\Translation\AutoTranslatableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
#[ORM\Table(name: 'plantfamily')]
#[ORM\Entity(repositoryClass: 'App\Entity\Repository\PlantfamilyRepository')]
class Plantfamily implements TranslatableInterface
{
use AutoTranslatableTrait;
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'string', unique: true, nullable: false)]
private $name;
#[ORM\Column(type: 'datetime', nullable: false)]
private $date_created;
#[ORM\OneToMany(targetEntity: 'App\Entity\Crop', mappedBy: 'plantfamily')]
private $crop;
#[ORM\Column(type: 'json', nullable: true)]
private $settings = [];
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\Column(nullable: true)]
private ?float $cultivation_break = null;
#[ORM\Column(length: 50, nullable: true)]
private ?string $nutrient_demand = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $latin_name = null;
public function __construct()
{
$this->crop = new ArrayCollection();
$this->date_created = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
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 getDateCreated(): ?\DateTimeInterface
{
return $this->date_created;
}
public function setDateCreated(\DateTimeInterface $date_created): self
{
$this->date_created = $date_created;
return $this;
}
/**
* @return Collection|Crop[]
*/
public function getCrop(): Collection
{
return $this->crop;
}
public function addCrop(Crop $crop): self
{
if (!$this->crop->contains($crop)) {
$this->crop[] = $crop;
$crop->setPlantfamily($this);
}
return $this;
}
public function removeCrop(Crop $crop): self
{
if ($this->crop->removeElement($crop)) {
// set the owning side to null (unless already changed)
if ($crop->getPlantfamily() === $this) {
$crop->setPlantfamily(null);
}
}
return $this;
}
public function getSettings(): ?array
{
return $this->settings;
}
public function setSettings(?array $settings): self
{
$this->settings = $settings;
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 getCultivationBreak(): ?float
{
return $this->cultivation_break;
}
public function setCultivationBreak(?float $cultivation_break): static
{
$this->cultivation_break = $cultivation_break;
return $this;
}
public function getNutrientDemand(): ?string
{
return $this->nutrient_demand;
}
public function setNutrientDemand(?string $nutrient_demand): static
{
$this->nutrient_demand = $nutrient_demand;
return $this;
}
public function getLatinName(): ?string
{
return $this->latin_name;
}
public function setLatinName(?string $latin_name): static
{
$this->latin_name = $latin_name;
return $this;
}
}