<?php
namespace App\Entity;
use App\Entity\Traits\TimestampableTrait;
use App\Repository\TreeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=TreeRepository::class)
*/
class Tree
{
use TimestampableTrait;
public const TREE_TYPE = 0;
public const BUSH_AND_PLANT_TYPE = 1;
public const INVASIVE_PLANT_TYPE = 0;
public const ENDEMIQUE_PLANT_TYPE = 1;
public const CATEGORIES_NAME = [
self::TREE_TYPE => 'Arbre (+ 3 mètres)',
self::BUSH_AND_PLANT_TYPE => 'Arbuste / plante (- 3 mètres)',
];
public const TYPE_NAME = [
self::INVASIVE_PLANT_TYPE => 'Plante interdite',
self::ENDEMIQUE_PLANT_TYPE => 'Plante endémique',
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $latinName;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="text")
*/
private $characteristics;
/**
* @ORM\Column(type="string", length=255)
*/
private $frenchName;
/**
* @ORM\Column(type="integer")
*/
private $taxref;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowed;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $creoleName;
/**
* @ORM\Column(type="smallint")
*/
private $category;
/**
* @ORM\OneToMany(targetEntity=TreeFile::class, mappedBy="tree", orphanRemoval=true, cascade={"persist"})
*/
private $treeFiles;
/**
* @ORM\OneToMany(targetEntity=DemandTree::class, mappedBy="tree")
*/
private $demandTrees;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $stock;
/**
* @ORM\Column(type="smallint")
*/
private $type = self::INVASIVE_PLANT_TYPE;
public function __construct()
{
$this->treeFiles = new ArrayCollection();
$this->demandTrees = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLatinName(): ?string
{
return $this->latinName;
}
public function setLatinName(string $latinName): self
{
$this->latinName = $latinName;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getCharacteristics(): ?string
{
return $this->characteristics;
}
public function setCharacteristics(string $characteristics): self
{
$this->characteristics = $characteristics;
return $this;
}
public function getFrenchName(): ?string
{
return $this->frenchName;
}
public function setFrenchName(string $frenchName): self
{
$this->frenchName = $frenchName;
return $this;
}
public function getTaxref(): ?int
{
return $this->taxref;
}
public function setTaxref(int $taxref): self
{
$this->taxref = $taxref;
return $this;
}
public function getAllowed(): ?bool
{
return $this->allowed;
}
public function setAllowed(bool $allowed): self
{
$this->allowed = $allowed;
return $this;
}
public function getCreoleName(): ?string
{
return $this->creoleName;
}
public function setCreoleName(?string $creoleName): self
{
$this->creoleName = $creoleName;
return $this;
}
public function getCategory(): ?int
{
return $this->category;
}
public function setCategory(int $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection|TreeFile[]
*/
public function getTreeFiles(): Collection
{
return $this->treeFiles;
}
public function addTreeFile(TreeFile $treeFile): self
{
if (!$this->treeFiles->contains($treeFile)) {
$this->treeFiles[] = $treeFile;
$treeFile->setTree($this);
}
return $this;
}
public function removeTreeFile(TreeFile $treeFile): self
{
if ($this->treeFiles->removeElement($treeFile)) {
// set the owning side to null (unless already changed)
if ($treeFile->getTree() === $this) {
$treeFile->setTree(null);
}
}
return $this;
}
/**
* @return Collection|DemandTree[]
*/
public function getDemandTrees(): Collection
{
return $this->demandTrees;
}
public function addDemandTree(DemandTree $demandTree): self
{
if (!$this->demandTrees->contains($demandTree)) {
$this->demandTrees[] = $demandTree;
$demandTree->setTree($this);
}
return $this;
}
public function removeDemandTree(DemandTree $demandTree): self
{
if ($this->demandTrees->removeElement($demandTree)) {
// set the owning side to null (unless already changed)
if ($demandTree->getTree() === $this) {
$demandTree->setTree(null);
}
}
return $this;
}
public function getStock(): ?int
{
return $this->stock;
}
public function setStock(?int $stock): self
{
$this->stock = $stock;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
}