src/Flexy/FrontBundle/Entity/CategoryPage.php line 16
<?php
namespace App\Flexy\FrontBundle\Entity;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\Entity\CategoryPageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Translatable;
use Gedmo\Mapping\Annotation as Gedmo;
#[ORM\Entity(repositoryClass: CategoryPageRepository::class)]
#[ApiResource]
class CategoryPage implements Translatable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Gedmo\Translatable]
private ?string $title = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Gedmo\Translatable]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true)]
#[Gedmo\Translatable]
private ?string $image = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $createdAt = null;
#[ORM\ManyToMany(targetEntity: Page::class, mappedBy: 'categories')]
private Collection $pages;
#[Gedmo\Locale]
private $locale;
public function __toString()
{
return (string) ($this->getTitle() ?? 'New category');
}
public function __construct()
{
$this->pages = 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 getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): static
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): static
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection<int, Page>
*/
public function getPages(): Collection
{
return $this->pages;
}
public function addPage(Page $page): static
{
if (!$this->pages->contains($page)) {
$this->pages->add($page);
}
return $this;
}
public function removePage(Page $page): static
{
$this->pages->removeElement($page);
return $this;
}
}