<?php
namespace App\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
#[ORM\MappedSuperclass()]
#[ORM\HasLifecycleCallbacks()]
class BaseEntity
{
#[ORM\Column(type: 'datetime')]
private DateTime $createdAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private DateTime $updatedAt;
#[ORM\Column(type: 'datetime', nullable: true)]
private DateTime|null $deletedAt;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private string $uuid;
#[ORM\Column(type: 'string', length: 255, unique: true, nullable: true)]
private string $urlSlug;
#[ORM\Column(type: 'text', length: 160, nullable: true)]
private string $ogDescription = '';
#[ORM\Column(type: 'boolean')]
private bool $active = true;
public function __construct()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
$this->uuid = Uuid::uuid4();
$this->urlSlug = uniqid('slug-', false).rand(0,100000000);
}
/**
* @return DateTime
*/
public function getUpdatedAt(): DateTime
{
return $this->updatedAt;
}
/**
* @param DateTime $updatedAt
*/
public function setUpdatedAt(DateTime $updatedAt): void
{
$this->updatedAt = $updatedAt;
}
/**
* @return DateTime|null
*/
public function getDeletedAt(): DateTime|null
{
return $this->deletedAt;
}
public function setDeletedAt( $deletedAt): void
{
$this->deletedAt = $deletedAt;
}
/**
* @return string
*/
public function getUrlSlug(): string
{
return $this->urlSlug;
}
/**
* @param string $urlSlug
*/
public function setUrlSlug(string $urlSlug): void
{
$this->urlSlug = $urlSlug;
}
/**
* @return DateTime
*/
public function getCreatedAt(): DateTime
{
return $this->createdAt;
}
/**
* @param DateTime $createdAt
*/
public function setCreatedAt(DateTime $createdAt): void
{
$this->createdAt = $createdAt;
}
/**
* @return string
*/
public function getUuid(): string
{
return $this->uuid;
}
/**
* @param UuidInterface $uuid
*/
public function setUuid(UuidInterface $uuid): void
{
$this->uuid = $uuid;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->active;
}
/**
* @param bool $active
*/
public function setActive(bool $active): void
{
$this->active = $active;
}
/**
* @return string
*/
public function getOgDescription(): string
{
return $this->ogDescription ?: '';
}
/**
* @param string $ogDescription
*/
public function setOgDescription(string $ogDescription): void
{
$this->ogDescription = $ogDescription;
}
}