mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-19 03:32:51 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,25 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Champs-Libres <info@champs-libres.coop>
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@@ -27,14 +17,25 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_main_notification",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(columns={"relatedEntityClass", "relatedEntityId"})
|
||||
* }
|
||||
* name="chill_main_notification",
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(columns={"relatedEntityClass", "relatedEntityId"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Notification
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=User::class)
|
||||
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
|
||||
*/
|
||||
private Collection $addressees;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
*/
|
||||
private DateTimeImmutable $date;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
@@ -48,21 +49,9 @@ class Notification
|
||||
private string $message;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="datetime_immutable")
|
||||
* @ORM\Column(type="json")
|
||||
*/
|
||||
private \DateTimeImmutable $date;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private User $sender;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity=User::class)
|
||||
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
|
||||
*/
|
||||
private Collection $addressees;
|
||||
private array $read;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=255)
|
||||
@@ -75,52 +64,21 @@ class Notification
|
||||
private int $relatedEntityId;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json")
|
||||
* @ORM\ManyToOne(targetEntity=User::class)
|
||||
* @ORM\JoinColumn(nullable=false)
|
||||
*/
|
||||
private array $read;
|
||||
private User $sender;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->addressees = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
public function addAddressee(User $addressee): self
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function setMessage(string $message): self
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDate(): ?\DateTimeImmutable
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
public function setDate(\DateTimeImmutable $date): self
|
||||
{
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSender(): ?User
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
public function setSender(?User $sender): self
|
||||
{
|
||||
$this->sender = $sender;
|
||||
if (!$this->addressees->contains($addressee)) {
|
||||
$this->addressees[] = $addressee;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -133,13 +91,39 @@ class Notification
|
||||
return $this->addressees;
|
||||
}
|
||||
|
||||
public function addAddressee(User $addressee): self
|
||||
public function getDate(): ?DateTimeImmutable
|
||||
{
|
||||
if (!$this->addressees->contains($addressee)) {
|
||||
$this->addressees[] = $addressee;
|
||||
}
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
return $this;
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getMessage(): ?string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function getRead(): array
|
||||
{
|
||||
return $this->read;
|
||||
}
|
||||
|
||||
public function getRelatedEntityClass(): ?string
|
||||
{
|
||||
return $this->relatedEntityClass;
|
||||
}
|
||||
|
||||
public function getRelatedEntityId(): ?int
|
||||
{
|
||||
return $this->relatedEntityId;
|
||||
}
|
||||
|
||||
public function getSender(): ?User
|
||||
{
|
||||
return $this->sender;
|
||||
}
|
||||
|
||||
public function removeAddressee(User $addressee): self
|
||||
@@ -149,9 +133,25 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelatedEntityClass(): ?string
|
||||
public function setDate(DateTimeImmutable $date): self
|
||||
{
|
||||
return $this->relatedEntityClass;
|
||||
$this->date = $date;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setMessage(string $message): self
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRead(array $read): self
|
||||
{
|
||||
$this->read = $read;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setRelatedEntityClass(string $relatedEntityClass): self
|
||||
@@ -161,11 +161,6 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRelatedEntityId(): ?int
|
||||
{
|
||||
return $this->relatedEntityId;
|
||||
}
|
||||
|
||||
public function setRelatedEntityId(int $relatedEntityId): self
|
||||
{
|
||||
$this->relatedEntityId = $relatedEntityId;
|
||||
@@ -173,14 +168,9 @@ class Notification
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRead(): array
|
||||
public function setSender(?User $sender): self
|
||||
{
|
||||
return $this->read;
|
||||
}
|
||||
|
||||
public function setRead(array $read): self
|
||||
{
|
||||
$this->read = $read;
|
||||
$this->sender = $sender;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user