<?phpnamespace App\Entity\Application;use App\Entity\User;use App\Repository\Application\NotificationRepository;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;use JMS\Serializer\Annotation as Serializer;/** * @ORM\Table(name="app_notification") * @ORM\Entity(repositoryClass=NotificationRepository::class) * @ORM\EntityListeners({"App\Listener\EntityListener"}) */class Notification implements TranslatableInterface{ use TranslatableTrait; /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="datetime") */ private $sendts; /** * @ORM\Column(type="boolean") */ private $sended = false; /** * @ORM\Column(type="datetime") */ private $createts; /** * @Serializer\Groups({"api"}) * @Serializer\SerializedName("type") * @ORM\Column(type="string") */ private string $type; /** * @ORM\ManyToOne(targetEntity="App\Entity\User") * @ORM\JoinColumn(nullable=true) */ private $createUser; /** * @ORM\Column(type="datetime", nullable=true) */ private $editts; /** * @ORM\ManyToOne(targetEntity="App\Entity\User") */ private $editUser; /** * @ORM\OneToMany(targetEntity=NotificationSeen::class, mappedBy="notification") */ private $notificationSeens; /** * @Serializer\Groups({"api"}) * @ORM\ManyToOne(targetEntity=Store::class) * @ORM\JoinColumn(nullable=true) */ private $store; /** * @ORM\Column(type="boolean") */ private $disabled = false; /** * @Serializer\VirtualProperty() * @Serializer\Groups({"api"}) * @Serializer\Inline() */ public function getVirtualTranslation() { return $this->translate(); } public function __construct() { if($this->getSendts() === null){ $this->setSendts(new \DateTime()); } $this->notificationSeens = new ArrayCollection(); } public function checkCollections(array $locales): void { foreach ( $locales as $locale ) { $this->addTranslation($this->translate($locale)); } $this->mergeNewTranslations(); } public function getId(): ?int { return $this->id; } public function getSendts(): ?\DateTimeInterface { return $this->sendts; } public function setSendts(\DateTimeInterface $sendts): self { $this->sendts = $sendts; return $this; } public function getCreatets(): ?\DateTimeInterface { return $this->createts; } public function setCreatets(\DateTimeInterface $createts): self { $this->createts = $createts; return $this; } public function getCreateUser(): ?User { return $this->createUser; } public function setCreateUser(?User $createUser): self { $this->createUser = $createUser; return $this; } public function getEditts(): ?\DateTimeInterface { return $this->editts; } public function setEditts(?\DateTimeInterface $editts): self { $this->editts = $editts; return $this; } public function getEditUser(): ?User { return $this->editUser; } public function setEditUser(?User $editUser): self { $this->editUser = $editUser; 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 bool */ public function isSended(): bool { return $this->sended; } /** * @param bool $sended */ public function setSended(bool $sended): void { $this->sended = $sended; } /** * @return Collection|NotificationSeen[] */ public function getNotificationSeens(): Collection { return $this->notificationSeens; } public function addNotificationSeen(NotificationSeen $notificationSeen): self { if (!$this->notificationSeens->contains($notificationSeen)) { $this->notificationSeens[] = $notificationSeen; $notificationSeen->setNotification($this); } return $this; } public function removeNotificationSeen(NotificationSeen $notificationSeen): self { if ($this->notificationSeens->removeElement($notificationSeen)) { // set the owning side to null (unless already changed) if ($notificationSeen->getNotification() === $this) { $notificationSeen->setNotification(null); } } return $this; } public function getStore(): ?Store { return $this->store; } public function setStore(?Store $store): self { $this->store = $store; return $this; } public function getType(): string { return $this->type; } public function setType(string $type): void { $this->type = $type; } public function isDisabled(): bool { return $this->disabled; } public function setDisabled(bool $disabled): void { $this->disabled = $disabled; }}