<?phpnamespace App\Entity;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity * @ORM\Table(name="progetti") */class Progetto{ /** * @var int * * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue */ private $id; /** * @var string * * @ORM\Column(type="string", length=150) */ private $name; /** * @var string|null * * @ORM\Column(type="text", nullable=true) */ private $description = null; /** * @var Servizio[]|null * * @ORM\OneToMany(targetEntity=Servizio::class, mappedBy="progetto") */ private $services; /** * @var Cliente|null * * @ORM\ManyToOne(targetEntity=Cliente::class, inversedBy="projects") */ private $client; /** * @var Collection * * @ORM\OneToMany(targetEntity=Progetto::class, mappedBy="parent") */ private $subprojects; /** * @var Progetto|null * * @ORM\ManyToOne(targetEntity=Progetto::class, inversedBy="subprojects") */ private $parent = null; public function __construct() { $this->services = new ArrayCollection(); $this->subprojects = new ArrayCollection(); } public function __toString(): string { return $this->getFullName(); } /** * @return int */ public function getId(): int { return $this->id; } /** * @param int $id * @return Progetto */ public function setId(int $id): Progetto { $this->id = $id; return $this; } /** * @return string */ public function getName(): string { return $this->name; } /** * @param string $name * @return Progetto */ public function setName(string $name): Progetto { $this->name = $name; return $this; } /** * @return string */ public function getDescription(): ?string { return $this->description; } /** * @param string $description * @return Progetto */ public function setDescription(?string $description): Progetto { $this->description = $description; return $this; } /** * @return Servizio[]|null */ public function getServices(): ?array { return $this->services; } /** * @param Servizio[]|null $services * @return Progetto */ public function setServices(?array $services): Progetto { $this->services = $services; return $this; } /** * @return Cliente|null */ public function getClient(): ?Cliente { return $this->client; } /** * @param Cliente $client * @return Progetto */ public function setClient(?Cliente $client): Progetto { $this->client = $client; return $this; } public function getParent(): ?Progetto { return $this->parent; } public function setParent(?Progetto $parent): Progetto { $this->parent = $parent; return $this; } public function getSubprojects(): Collection { return $this->subprojects; } public function setSubprojects(Collection $subprojects): Progetto { $this->subprojects = $subprojects; return $this; } public function getFullName() { $name = $this->getName(); $start = $this; while($parent = $start->getParent()) { $name = $parent->getName().' - '.$name; $start = $parent; } return $name; }}