<?php
namespace App\Entity;
use App\Repository\AlertRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Gedmo\Translatable\Translatable;
use App\Entity\Translation\AlertTranslation;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=AlertRepository::class)
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false,hardDelete=false)
* @Gedmo\TranslationEntity(class="App\Entity\Translation\AlertTranslation")
*/
class Alert implements Translatable
{
use TimestampableEntity;
use SetTranslationsTrait;
public const FIELDS = [
'content'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups("alert:list", "alert:item")
*/
private $id;
/**
* @ORM\Column(type="text")
* @Gedmo\Translatable
* @Groups("alert:list", "alert:item")
*/
private $content;
/**
* @var string
* @Ignore()
*/
private $contentEn;
/**
* @var string
* @Ignore()
*/
private $contentCa;
/**
* @ORM\Column(type="boolean")
* @Groups("alert:list", "alert:item")
*/
private $enabled;
/**
* @ORM\OneToMany(
* targetEntity="App\Entity\Translation\AlertTranslation",
* mappedBy="object",
* cascade={"persist", "remove"}
* )
* @Ignore()
*/
private $translations;
/**
* @ORM\Column(type="datetime", nullable=true)
* @var \DateTime|null
*/
protected $deletedAt;
/**
* Alert constructor.
*/
public function __construct()
{
$this->enabled = true;
$this->translations = new ArrayCollection();
}
public function __toString()
{
return $this->content;
}
public function getId(): ?int
{
return $this->id;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
/**
* @return mixed
*/
public function getContentEn(): ?string
{
return $this->contentEn;
}
/**
* @param string|null $contentEn
*
* @return $this
*/
public function setContentEn(?string $contentEn): self
{
$this->contentEn = $contentEn;
return $this;
}
/**
* @return mixed
*/
public function getContentCa(): ?string
{
return $this->contentCa;
}
/**
* @param string|null $contentCa
*
* @return $this
*/
public function setContentCa(?string $contentCa): self
{
$this->contentCa = $contentCa;
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $active): self
{
$this->enabled = $active;
return $this;
}
/**
* @Gedmo\Locale
* Used locale to override Translation listener`s locale
* this is not a mapped field of entity metadata, just a simple property
*/
private $locale;
public function setTranslatableLocale($locale)
{
$this->locale = $locale;
}
public function getTranslations()
{
return $this->translations;
}
public function addTranslation(AlertTranslation $t)
{
if (!$this->translations->contains($t)) {
$this->translations[] = $t;
$t->setObject($this);
}
}
/**
* Set or clear the deleted at timestamp.
*
* @return self
*/
public function setDeletedAt(\DateTime $deletedAt = null)
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* Get the deleted at timestamp value. Will return null if
* the entity has not been soft deleted.
*
* @return \DateTime|null
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
}