<?php
namespace App\Entity;
use App\Repository\NodeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NodeRepository::class)]
#[ORM\InheritanceType("SINGLE_TABLE")]
#[ORM\DiscriminatorMap(["DISCOUNT" => "App\Entity\Discount", "BUSINESS" => "App\Entity\Business", "NEWS" => "App\Entity\News", "PAGE" => "App\Entity\Page"])]
class Node
{
#[ORM\Id]
#[ORM\Column(type: "integer")]
#[ORM\GeneratedValue(strategy: "AUTO")]
private ?int $id = null;
#[ORM\Column(type: "string", length: 255, nullable: false)]
protected ?string $title = null;
#[ORM\Column(type: "text", nullable: true)]
private ?string $description = null;
#[ORM\Column(type: "boolean", nullable: false)]
private bool $published;
#[ORM\OneToMany(targetEntity: \App\Entity\Node::class, mappedBy: "parent")]
private Collection $nodes;
#[ORM\ManyToOne(targetEntity: \App\Entity\Node::class, inversedBy: "nodes")]
#[ORM\JoinColumn(name: "parent", referencedColumnName: "id")]
protected ?Node $parent = null;
#[ORM\Column(length: 255)]
private ?string $url = null;
#[ORM\OneToMany(mappedBy: 'node', targetEntity: OpeningHours::class, cascade: ['persist'])]
private Collection $openingHours;
#[ORM\ManyToMany(targetEntity: Tag::class, inversedBy: 'nodes', cascade: ['persist'])]
protected Collection $tags;
public function __construct()
{
$this->openingHours = new ArrayCollection();
$this->tags = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): static
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function isPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): static
{
$this->published = $published;
return $this;
}
public function getNodes()
{
return $this->nodes;
}
public function setNodes($nodes): void
{
$this->nodes = $nodes;
}
/**
* @return mixed
*/
public function getParent()
{
return $this->parent;
}
/**
* @param mixed $parent
*/
public function setParent($parent): void
{
$this->parent = $parent;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): static
{
$this->url = $url;
return $this;
}
/**
* @return Collection<int, OpeningHours>
*/
public function getOpeningHours(): Collection
{
return $this->openingHours;
}
public function addOpeningHour(OpeningHours $openingHour): static
{
if (!$this->openingHours->contains($openingHour)) {
$this->openingHours->add($openingHour);
$openingHour->setNode($this);
}
return $this;
}
public function removeOpeningHour(OpeningHours $openingHour): static
{
if ($this->openingHours->contains($openingHour)) {
$this->openingHours->remove($openingHour);
}
return $this;
}
/**
* @return Collection<int, Tag>
*/
public function getTags(): Collection
{
return $this->tags;
}
public function addTag(Tag $tag): static
{
if (!$this->tags->contains($tag)) {
$this->tags->add($tag);
}
return $this;
}
public function removeTag(Tag $tag): static
{
$this->tags->removeElement($tag);
return $this;
}
}