<?php
namespace App\Entity\Web;
use App\Repository\Web\NewsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Behaviors\TranslatableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
/**
* @ORM\Table(name="web_news")
* @ORM\Entity(repositoryClass=NewsRepository::class)
* @ORM\EntityListeners({"App\Listener\EntityListener"})
*/
class News implements TranslatableInterface
{
use TranslatableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private int $id;
/**
* @ORM\Column(type="datetime")
*/
private $datePublic;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateFrom = null;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateTo = null;
/**
* @ORM\Column(type="boolean")
*/
private $isActive = true;
/**
* @ORM\Column(type="boolean")
*/
private $isPopup = false;
/**
* @ORM\Column(type="datetime")
*/
private $createts;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
* @ORM\JoinColumn(nullable=false)
*/
private $createUser;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $editts;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User")
*/
private $editUser;
/**
* @ORM\OneToMany(targetEntity=NewsStore::class,cascade={"all"}, mappedBy="news", orphanRemoval=true)
*/
private $newsStores;
public function __construct()
{
//$this->setDefaultLocale(\Locale::getDefault());
//$trans = new NewsTranslation($this->getDefaultLocale());
//$this->addTranslation($trans);
if($this->getDatePublic() === null){
$this->setDatePublic(new \DateTime());
$this->setDateFrom(new \DateTime());
$this->setDateTo(new \DateTime());
}
$this->newsStores = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): self
{
$this->isActive = $isActive;
return $this;
}
public function __call($method, $arguments)
{
$ret = $this->proxyCurrentLocaleTranslation($method, $arguments);
if(empty($ret)) {
$ret = call_user_func_array( [ $this->translate( \Locale::getDefault() ), $method ], $arguments );
}
return $ret;
}
/**
* @return mixed
*/
public function getCreatets()
{
return $this->createts;
}
/**
* @param mixed $createts
*/
public function setCreatets($createts): void
{
$this->createts = $createts;
}
/**
* @return mixed
*/
public function getCreateUser()
{
return $this->createUser;
}
/**
* @param mixed $createUser
*/
public function setCreateUser($createUser): void
{
$this->createUser = $createUser;
}
/**
* @return mixed
*/
public function getEditts()
{
return $this->editts;
}
/**
* @param mixed $editts
*/
public function setEditts($editts): void
{
$this->editts = $editts;
}
/**
* @return mixed
*/
public function getEditUser()
{
return $this->editUser;
}
/**
* @param mixed $editUser
*/
public function setEditUser($editUser): void
{
$this->editUser = $editUser;
}
/**
* @return mixed
*/
public function getDatePublic()
{
return $this->datePublic;
}
/**
* @param mixed $datePublic
*/
public function setDatePublic($datePublic): void
{
$this->datePublic = $datePublic;
}
/**
* @return bool
*/
public function isPopup(): bool
{
return $this->isPopup;
}
/**
* @param bool $isPopup
*/
public function setIsPopup(bool $isPopup): void
{
$this->isPopup = $isPopup;
}
/**
* @return Collection<int, NewsStore>
*/
public function getNewsStores(): Collection
{
return $this->newsStores;
}
public function addNewsStore(NewsStore $newsStore): self
{
if (!$this->newsStores->contains($newsStore)) {
$this->newsStores[] = $newsStore;
$newsStore->setNews($this);
}
return $this;
}
public function removeNewsStore(NewsStore $newsStore): self
{
if ($this->newsStores->removeElement($newsStore)) {
// set the owning side to null (unless already changed)
if ($newsStore->getNews() === $this) {
$newsStore->setNews(null);
}
}
return $this;
}
/**
* Get DateFrom
*
* @return mixed
*/
public function getDateFrom()
{
return $this->dateFrom;
}
/**
* Set DateFrom
*
* @param mixed $dateFrom
*/
public function setDateFrom( $dateFrom )
{
$this->dateFrom = $dateFrom;
}
/**
* Get DateTo
*
* @return mixed
*/
public function getDateTo()
{
return $this->dateTo;
}
/**
* Set DateTo
*
* @param mixed $dateTo
*/
public function setDateTo( $dateTo )
{
$this->dateTo = $dateTo;
}
}