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

@@ -36,15 +36,11 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Range;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* @ORM\Table(
* name="chill_calendar.calendar",
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
* )
*
* @ORM\Entity
*/
#[Serializer\DiscriminatorMap(typeProperty: 'type', mapping: ['chill_calendar_calendar' => Calendar::class])]
#[ORM\Entity]
#[ORM\Table(name: 'chill_calendar.calendar')]
#[ORM\UniqueConstraint(name: 'idx_calendar_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])]
class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCentersInterface
{
use RemoteCalendarTrait;
@@ -86,105 +82,75 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
public ?User $previousMainUser = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod", inversedBy="calendars")
*/
#[Serializer\Groups(['calendar:read', 'read'])]
#[ORM\ManyToOne(targetEntity: \Chill\PersonBundle\Entity\AccompanyingPeriod::class, inversedBy: 'calendars')]
private ?AccompanyingPeriod $accompanyingPeriod = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\Activity")
*/
#[ORM\ManyToOne(targetEntity: \Chill\ActivityBundle\Entity\Activity::class)]
private ?Activity $activity = null;
/**
* @ORM\OneToOne(targetEntity="CalendarRange", inversedBy="calendar")
*/
#[Serializer\Groups(['calendar:read', 'read'])]
#[ORM\OneToOne(targetEntity: \CalendarRange::class, inversedBy: 'calendar')]
private ?CalendarRange $calendarRange = null;
/**
* @ORM\ManyToOne(targetEntity="CancelReason")
*/
#[ORM\ManyToOne(targetEntity: \CancelReason::class)]
private ?CancelReason $cancelReason = null;
/**
* @ORM\Embedded(class=CommentEmbeddable::class, columnPrefix="comment_")
*/
#[Serializer\Groups(['calendar:read', 'read', 'docgen:read'])]
#[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')]
private CommentEmbeddable $comment;
/**
* @ORM\Column(type="integer", nullable=false, options={"default": 0})
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 0])]
private int $dateTimeVersion = 0;
/**
* @var Collection<CalendarDoc>
*
* @ORM\OneToMany(targetEntity=CalendarDoc::class, mappedBy="calendar", orphanRemoval=true)
*/
#[ORM\OneToMany(targetEntity: CalendarDoc::class, mappedBy: 'calendar', orphanRemoval: true)]
private Collection $documents;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.An end date is required')]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\OneToMany(
* targetEntity=Invite::class,
* mappedBy="calendar",
* orphanRemoval=true,
* cascade={"persist", "remove", "merge", "detach"}
* )
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_invites")
*
* @var Collection&Selectable<int, Invite>
*/
#[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\OneToMany(targetEntity: Invite::class, mappedBy: 'calendar', orphanRemoval: true, cascade: ['persist', 'remove', 'merge', 'detach'])]
#[ORM\JoinTable(name: 'chill_calendar.calendar_to_invites')]
private Collection&Selectable $invites;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Location")
*/
#[Serializer\Groups(['read', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A location is required')]
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\Location::class)]
private ?Location $location = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A main user is mandatory')]
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
private ?User $mainUser = null;
/**
* @ORM\ManyToOne(targetEntity=Person::class)
*
* @ORM\JoinColumn(nullable=true)
*/
#[ORM\ManyToOne(targetEntity: Person::class)]
#[ORM\JoinColumn(nullable: true)]
private ?Person $person = null;
/**
* @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\Person", inversedBy="calendars")
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_persons")
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*
@@ -192,58 +158,50 @@ class Calendar implements TrackCreationInterface, TrackUpdateInterface, HasCente
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\Count(min: 1, minMessage: 'calendar.At least {{ limit }} person is required.')]
#[ORM\ManyToMany(targetEntity: \Chill\PersonBundle\Entity\Person::class, inversedBy: 'calendars')]
#[ORM\JoinTable(name: 'chill_calendar.calendar_to_persons')]
private Collection $persons;
/**
* @ORM\Embedded(class=PrivateCommentEmbeddable::class, columnPrefix="privateComment_")
*/
#[Serializer\Groups(['calendar:read'])]
#[ORM\Embedded(class: PrivateCommentEmbeddable::class, columnPrefix: 'privateComment_')]
private PrivateCommentEmbeddable $privateComment;
/**
* @var Collection<ThirdParty>
*
* @ORM\ManyToMany(targetEntity="Chill\ThirdPartyBundle\Entity\ThirdParty")
*
* @ORM\JoinTable(name="chill_calendar.calendar_to_thirdparties")
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[ORM\ManyToMany(targetEntity: \Chill\ThirdPartyBundle\Entity\ThirdParty::class)]
#[ORM\JoinTable(name: 'chill_calendar.calendar_to_thirdparties')]
private Collection $professionals;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
#[Serializer\Groups(['docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)]
private ?bool $sendSMS = false;
/**
* @ORM\Column(type="text", nullable=false, options={"default": Calendar::SMS_PENDING})
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => Calendar::SMS_PENDING])]
private string $smsStatus = self::SMS_PENDING;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light', 'docgen:read'])]
#[Assert\NotNull(message: 'calendar.A start date is required')]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\Column(type="string", length=255, nullable=false, options={"default": "valid"})
*
* @Serializer\Context(normalizationContext={"read"}, groups={"calendar:light"})
*/
#[Serializer\Groups(['calendar:read', 'read', 'calendar:light'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255, nullable: false, options: ['default' => 'valid'])]
private string $status = self::STATUS_VALID;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
#[Serializer\Groups(['docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: true)]
private ?bool $urgent = false;
public function __construct()

View File

@@ -20,50 +20,35 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
*
* @ORM\Table(
* name="chill_calendar.calendar_doc",
* )
*/
#[ORM\Entity]
#[ORM\Table(name: 'chill_calendar.calendar_doc')]
class CalendarDoc implements TrackCreationInterface, TrackUpdateInterface
{
use TrackCreationTrait;
use TrackUpdateTrait;
/**
* @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="documents")
*
* @ORM\JoinColumn(nullable=false)
*/
#[ORM\ManyToOne(targetEntity: Calendar::class, inversedBy: 'documents')]
#[ORM\JoinColumn(nullable: false)]
private Calendar $calendar;
/**
* @ORM\Column(type="integer", nullable=false, options={"default": 0})
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER, nullable: false, options: ['default' => 0])]
private int $datetimeVersion = 0;
/**
* @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="boolean", nullable=false, options={"default": false})
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN, nullable: false, options: ['default' => false])]
private bool $trackDateTimeVersion = false;
public function __construct(Calendar $calendar, /**
* @ORM\ManyToOne(targetEntity=StoredObject::class, cascade={"persist"})
*
* @ORM\JoinColumn(nullable=false)
*/
public function __construct(Calendar $calendar,
#[ORM\ManyToOne(targetEntity: StoredObject::class, cascade: ['persist'])]
#[ORM\JoinColumn(nullable: false)]
private ?StoredObject $storedObject)
{
$this->setCalendar($calendar);

View File

@@ -21,14 +21,10 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(
* name="chill_calendar.calendar_range",
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_range_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
* )
*
* @ORM\Entity
*/
#[ORM\Entity]
#[ORM\Table(name: 'chill_calendar.calendar_range')]
#[ORM\UniqueConstraint(name: 'idx_calendar_range_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])]
class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
{
use RemoteCalendarTrait;
@@ -37,49 +33,36 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
use TrackUpdateTrait;
/**
* @ORM\OneToOne(targetEntity=Calendar::class, mappedBy="calendarRange")
*/
#[ORM\OneToOne(targetEntity: Calendar::class, mappedBy: 'calendarRange')]
private ?Calendar $calendar = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
private ?\DateTimeImmutable $endDate = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[Groups(['read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\ManyToOne(targetEntity=Location::class)
*
* @ORM\JoinColumn(nullable=false)
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: Location::class)]
#[ORM\JoinColumn(nullable: false)]
private ?Location $location = null;
/**
* @ORM\Column(type="datetime_immutable", nullable=false)
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DATETIME_IMMUTABLE, nullable: false)]
private ?\DateTimeImmutable $startDate = null;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*/
#[Groups(['read', 'write', 'calendar:read'])]
#[Assert\NotNull]
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
private ?User $user = null;
public function getCalendar(): ?Calendar

View File

@@ -14,11 +14,9 @@ namespace Chill\CalendarBundle\Entity;
use Chill\CalendarBundle\Repository\CancelReasonRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="chill_calendar.cancel_reason")
*
* @ORM\Entity(repositoryClass=CancelReasonRepository::class)
*/
#[ORM\Entity(repositoryClass: CancelReasonRepository::class)]
#[ORM\Table(name: 'chill_calendar.cancel_reason')]
class CancelReason
{
final public const CANCELEDBY_DONOTCOUNT = 'CANCELEDBY_DONOTCOUNT';
@@ -27,28 +25,19 @@ class CancelReason
final public const CANCELEDBY_USER = 'CANCELEDBY_USER';
/**
* @ORM\Column(type="boolean")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::BOOLEAN)]
private ?bool $active = null;
/**
* @ORM\Column(type="string", length=255)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private ?string $canceledBy = null;
/**
* @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="json")
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private array $name = [];
public function getActive(): ?bool

View File

@@ -25,13 +25,11 @@ use Symfony\Component\Serializer\Annotation as Serializer;
* The event/calendar in the user may have a different id than the mainUser. We add then fields to store the
* remote id of this event in the remote calendar.
*
* @ORM\Table(
* name="chill_calendar.invite",
* uniqueConstraints={@ORM\UniqueConstraint(name="idx_calendar_invite_remote", columns={"remoteId"}, options={"where": "remoteId <> ''"})}
* )
*
* @ORM\Entity
*/
#[ORM\Entity]
#[ORM\Table(name: 'chill_calendar.invite')]
#[ORM\UniqueConstraint(name: 'idx_calendar_invite_remote', columns: ['remoteId'], options: ['where' => "remoteId <> ''"])]
class Invite implements TrackUpdateInterface, TrackCreationInterface
{
use RemoteCalendarTrait;
@@ -58,33 +56,24 @@ class Invite implements TrackUpdateInterface, TrackCreationInterface
final public const TENTATIVELY_ACCEPTED = 'tentative';
/**
* @ORM\ManyToOne(targetEntity=Calendar::class, inversedBy="invites")
*/
#[ORM\ManyToOne(targetEntity: Calendar::class, inversedBy: 'invites')]
private ?Calendar $calendar = null;
/**
* @ORM\Id
*
* @ORM\GeneratedValue
*
* @ORM\Column(type="integer")
*/
#[Serializer\Groups(groups: ['calendar:read', 'read'])]
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* @ORM\Column(type="text", nullable=false, options={"default": "pending"})
*/
#[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, nullable: false, options: ['default' => 'pending'])]
private string $status = self::PENDING;
/**
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\User")
*
* @ORM\JoinColumn(nullable=false)
*/
#[Serializer\Groups(groups: ['calendar:read', 'read', 'docgen:read'])]
#[ORM\ManyToOne(targetEntity: \Chill\MainBundle\Entity\User::class)]
#[ORM\JoinColumn(nullable: false)]
private ?User $user = null;
public function getCalendar(): ?Calendar

View File

@@ -30,14 +30,10 @@ trait RemoteCalendarTrait
*/
public bool $preventEnqueueChanges = false;
/**
* @ORM\Column(type="json", options={"default": "[]"}, nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON, options: ['default' => '[]'], nullable: false)]
private array $remoteAttributes = [];
/**
* @ORM\Column(type="text", options={"default": ""}, nullable=false)
*/
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::TEXT, options: ['default' => ''], nullable: false)]
private string $remoteId = '';
public function addRemoteAttributes(array $remoteAttributes): self