Apply rector rules: add annotation for doctrine mapping

This commit is contained in:
2024-04-05 00:01:30 +02:00
parent 579bd829f8
commit 72016e1a21
124 changed files with 1724 additions and 3770 deletions

View File

@@ -18,24 +18,14 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_main_notification",
* indexes={
*
* @ORM\Index(name="chill_main_notification_related_entity_idx", columns={"relatedentityclass", "relatedentityid"})
* }
* )
*
* @ORM\HasLifecycleCallbacks
*/
#[ORM\Entity]
#[ORM\HasLifecycleCallbacks]
#[ORM\Table(name: 'chill_main_notification')]
#[ORM\Index(name: 'chill_main_notification_related_entity_idx', columns: ['relatedentityclass', 'relatedentityid'])]
class Notification implements TrackUpdateInterface
{
/**
* @ORM\Column(type="text", nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false)]
private string $accessKey;
private array $addedAddresses = [];
@@ -43,19 +33,18 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_user")
*/
#[ORM\ManyToMany(targetEntity: User::class)]
#[ORM\JoinTable(name: 'chill_main_notification_addresses_user')]
private Collection $addressees;
/**
* a list of destinee which will receive notifications.
*
* @var array|string[]
*
* @ORM\Column(type="json")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private array $addressesEmails = [];
/**
@@ -70,73 +59,54 @@ class Notification implements TrackUpdateInterface
/**
* @var Collection<NotificationComment>
*
* @ORM\OneToMany(targetEntity=NotificationComment::class, mappedBy="notification", orphanRemoval=true)
*
* @ORM\OrderBy({"createdAt": "ASC"})
*/
#[ORM\OneToMany(targetEntity: NotificationComment::class, mappedBy: 'notification', orphanRemoval: true)]
#[ORM\OrderBy(['createdAt' => \Doctrine\Common\Collections\Criteria::ASC])]
private Collection $comments;
/**
* @ORM\Column(type="datetime_immutable")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
private \DateTimeImmutable $date;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\Column(type="text")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT)]
private string $message = '';
/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private string $relatedEntityClass = '';
/**
* @ORM\Column(type="integer")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private int $relatedEntityId;
private array $removedAddresses = [];
/**
* @ORM\ManyToOne(targetEntity=User::class)
*
* @ORM\JoinColumn(nullable=true)
*/
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(nullable: true)]
private ?User $sender = null;
/**
* @ORM\Column(type="text", options={"default": ""})
*/
#[Assert\NotBlank(message: 'notification.Title must be defined')]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''])]
private string $title = '';
/**
* @var Collection<User>
*
* @ORM\ManyToMany(targetEntity=User::class)
*
* @ORM\JoinTable(name="chill_main_notification_addresses_unread")
*/
#[ORM\ManyToMany(targetEntity: User::class)]
#[ORM\JoinTable(name: 'chill_main_notification_addresses_unread')]
private Collection $unreadBy;
/**
* @ORM\Column(type="datetime_immutable")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE)]
private ?\DateTimeImmutable $updatedAt = null;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
#[ORM\ManyToOne(targetEntity: User::class)]
private ?User $updatedBy = null;
public function __construct()
@@ -312,9 +282,7 @@ class Notification implements TrackUpdateInterface
return $this->addUnreadBy($user);
}
/**
* @ORM\PreFlush
*/
#[ORM\PreFlush]
public function registerUnread()
{
foreach ($this->addedAddresses as $addressee) {