<?php
namespace App\Entity;
use App\Repository\NewsArticleRepository;
use DateTime;
use DateTimeInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=NewsArticleRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class NewsArticle
{
public const IMAGE_PREVIEW_LARGE_DIR = 'large';
public const IMAGE_PREVIEW_SMALL_DIR = 'small';
/**
* @ORM\Column(type="integer", options={"unsigned":true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private ?int $id;
/**
* @ORM\Column(type="text")
*/
private ?string $content = '';
/**
* @ORM\Column(type="boolean")
*/
private bool $archived = false;
/**
* @ORM\Column(type="datetime")
*/
private ?DateTimeInterface $datePosted;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $imageFilename = null;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $thumbnailFilename = null;
/**
* @ORM\Column(type="string", length=127)
*/
private ?string $title = '';
/**
* @ORM\Column(type="datetime")
*/
private ?DateTimeInterface $dateCreated;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeInterface $dateModified;
/**
* @ORM\Column(type="boolean")
*/
private bool $published;
/**
* @ORM\PrePersist()
*/
public function prePersist(): void
{
$this->setDateCreated(new DateTime());
}
/**
* @ORM\PreUpdate()
*/
public function preUpdate(): void
{
$this->setDateModified(new DateTime());
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getDateCreated(): ?DateTimeInterface
{
return $this->dateCreated;
}
public function setDateCreated(DateTimeInterface $dateCreated): self
{
$this->dateCreated = $dateCreated;
return $this;
}
public function getDateModified(): ?DateTimeInterface
{
return $this->dateModified;
}
public function setDateModified(?DateTimeInterface $dateModified): self
{
$this->dateModified = $dateModified;
return $this;
}
public function getDatePosted(): ?DateTimeInterface
{
return $this->datePosted;
}
public function setDatePosted(DateTimeInterface $datePosted): self
{
$this->datePosted = $datePosted;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getImageFilename(): ?string
{
return $this->imageFilename;
}
public function setImageFilename(?string $imageFilename): self
{
$this->imageFilename = $imageFilename;
return $this;
}
/**
* @return string|null
*/
public function getThumbnailFilename(): ?string
{
return $this->thumbnailFilename;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @param string|null $thumbnailFilename
* @return NewsArticle
*/
public function setThumbnailFilename(?string $thumbnailFilename): NewsArticle
{
$this->thumbnailFilename = $thumbnailFilename;
return $this;
}
public function getImageFilenameWithoutExtension() :string
{
return substr($this->getImageFilename(), 0, strrpos($this->getImageFilename(), "."));
}
/**
* @return bool
*/
public function isArchived(): bool
{
return $this->archived;
}
/**
* @param bool $archived
* @return NewsArticle
*/
public function setArchived(bool $archived): NewsArticle
{
$this->archived = $archived;
return $this;
}
public function isPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): self
{
$this->published = $published;
return $this;
}
}