diff --git a/composer.json b/composer.json index 6f4d429..a789c70 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,7 @@ ], "require": { "php": "^8.1", + "doctrine/doctrine-bundle": "^2.12", "phpcr/phpcr-migrations-bundle": "^1.6", "sulu/sulu": "^2.5", "sulu/automation-bundle": "^2.1", @@ -28,8 +29,7 @@ "symfony/http-kernel": "^6.2 | ^7.0", "symfony/intl": "^6.2 | ^7.0", "symfony/translation": "^6.2 | ^7.0", - "symfony/security-core": "^6.2 | ^7.0", - "doctrine/doctrine-bundle": "^2.11" + "symfony/security-core": "^6.2 | ^7.0" }, "require-dev": { "jackalope/jackalope-doctrine-dbal": "^1.3.4", diff --git a/src/Entity/Event.php b/src/Entity/Event.php index a844163..2451439 100644 --- a/src/Entity/Event.php +++ b/src/Entity/Event.php @@ -6,6 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use JMS\Serializer\Annotation as Serializer; use Manuxi\SuluEventBundle\Entity\Interfaces\AuditableTranslatableInterface; @@ -16,12 +17,10 @@ use Manuxi\SuluEventBundle\Entity\Traits\RouteTranslatableTrait; use Manuxi\SuluEventBundle\Entity\Traits\ShowAuthorTranslatableTrait; use Manuxi\SuluEventBundle\Entity\Traits\ShowDateTranslatableTrait; +use Manuxi\SuluEventBundle\Repository\EventRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventRepository") - */ +#[ORM\Entity(repositoryClass: EventRepository::class)] +#[ORM\Table(name: 'app_event')] class Event implements AuditableTranslatableInterface { public const RESOURCE_KEY = 'events'; @@ -36,68 +35,44 @@ class Event implements AuditableTranslatableInterface use ImageTranslatableTrait; use ShowAuthorTranslatableTrait; use ShowDateTranslatableTrait; - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] private ?int $id = null; - /** - * @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventSeo", mappedBy="event", cascade={"persist", "remove"}) - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToOne(mappedBy: 'event', targetEntity: EventSeo::class, cascade: ['persist', 'remove'])] private ?EventSeo $eventSeo = null; - /** - * @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventExcerpt", mappedBy="event", cascade={"persist", "remove"}) - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToOne(mappedBy: 'event', targetEntity: EventExcerpt::class, cascade: ['persist', 'remove'])] private ?EventExcerpt $eventExcerpt = null; - /** - * @ORM\Column(type="boolean", nullable=false) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: false)] private bool $enabled; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $startDate = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true) - */ + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)] private ?\DateTimeImmutable $endDate = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $email = null; - /** - * @ORM\Column(type="string", nullable=true) - */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $phoneNumber = null; - /** - * @ORM\Column(type="json", nullable=true) - */ + #[ORM\Column(type: Types::JSON, nullable: true)] private ?array $images = null; - /** - * @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Location") - * @ORM\JoinColumn(onDelete="SET NULL") - */ + #[ORM\ManyToOne(targetEntity: Location::class)] + #[ORM\JoinColumn(onDelete: 'SET NULL')] private ?Location $location = null; - /** - * @var Collection - * @ORM\OneToMany(targetEntity="Manuxi\SuluEventBundle\Entity\EventTranslation", mappedBy="event", cascade={"ALL"}, indexBy="locale", fetch="EXTRA_LAZY") - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToMany(mappedBy: 'event', targetEntity: EventTranslation::class, cascade: ['all'], fetch: 'EXTRA_LAZY', indexBy: 'locale')] private Collection $translations; private string $locale = 'de'; @@ -172,9 +147,7 @@ public function setLocation(?Location $location): self return $this; } - /** - * @Serializer\VirtualProperty - */ + #[Serializer\VirtualProperty] public function getLocationId(): ?int { if (!$this->location) { @@ -184,9 +157,7 @@ public function getLocationId(): ?int return $this->location->getId(); } - /** - * @Serializer\VirtualProperty(name="title") - */ + #[Serializer\VirtualProperty(name: "title")] public function getTitle(): ?string { $translation = $this->getTranslation($this->locale); @@ -208,9 +179,7 @@ public function setTitle(string $title): self return $this; } - /** - * @Serializer\VirtualProperty(name="subtitle") - */ + #[Serializer\VirtualProperty(name: "subtitle")] public function getSubtitle(): ?string { $translation = $this->getTranslation($this->locale); @@ -232,9 +201,7 @@ public function setSubtitle(?string $subtitle): self return $this; } - /** - * @Serializer\VirtualProperty(name="summary") - */ + #[Serializer\VirtualProperty(name: "summary")] public function getSummary(): ?string { $translation = $this->getTranslation($this->locale); @@ -256,9 +223,7 @@ public function setSummary(?string $summary): self return $this; } - /** - * @Serializer\VirtualProperty(name="text") - */ + #[Serializer\VirtualProperty(name: "text")] public function getText(): ?string { $translation = $this->getTranslation($this->locale); @@ -280,9 +245,7 @@ public function setText(string $text): self return $this; } - /** - * @Serializer\VirtualProperty(name="footer") - */ + #[Serializer\VirtualProperty(name: "footer")] public function getFooter(): ?string { $translation = $this->getTranslation($this->locale); @@ -336,9 +299,7 @@ public function setEventExcerpt(?EventExcerpt $eventExcerpt): self return $this; } - /** - * @Serializer\VirtualProperty(name="ext") - */ + #[Serializer\VirtualProperty(name: "ext")] public function getExt(): array { return $this->ext; @@ -407,9 +368,7 @@ private function initExt(): self return $this; } - /** - * @Serializer\VirtualProperty("availableLocales") - */ + #[Serializer\VirtualProperty(name: "availableLocales")] public function getAvailableLocales(): array { return \array_values($this->translations->getKeys()); diff --git a/src/Entity/EventExcerpt.php b/src/Entity/EventExcerpt.php index 4dbe53b..93f8111 100644 --- a/src/Entity/EventExcerpt.php +++ b/src/Entity/EventExcerpt.php @@ -13,30 +13,22 @@ use Manuxi\SuluEventBundle\Entity\Interfaces\ExcerptTranslatableInterface; use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTrait; use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTranslatableTrait; +use Manuxi\SuluEventBundle\Repository\EventExcerptRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event_excerpt") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventExcerptRepository") - */ +#[ORM\Entity(repositoryClass: EventExcerptRepository::class)] +#[ORM\Table(name: 'app_event_excerpt')] class EventExcerpt implements ExcerptInterface, ExcerptTranslatableInterface { use ExcerptTrait; use ExcerptTranslatableTrait; - /** - * @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Event", inversedBy="eventExcerpt", cascade={"persist", "remove"}) - * @JoinColumn(name="event_id", referencedColumnName="id", nullable=false) - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToOne(inversedBy: 'eventExcerpt', targetEntity: Event::class, cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(name: 'event_id', referencedColumnName: "id", nullable: false)] private ?Event $event = null; - /** - * @ORM\OneToMany(targetEntity="EventExcerptTranslation", mappedBy="eventExcerpt", cascade={"ALL"}, indexBy="locale") - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToMany(mappedBy: 'eventExcerpt', targetEntity: EventExcerptTranslation::class, cascade: ['all'], indexBy: 'locale')] private Collection $translations; public function __construct() diff --git a/src/Entity/EventExcerptTranslation.php b/src/Entity/EventExcerptTranslation.php index 791e7c9..c673218 100644 --- a/src/Entity/EventExcerptTranslation.php +++ b/src/Entity/EventExcerptTranslation.php @@ -4,24 +4,19 @@ namespace Manuxi\SuluEventBundle\Entity; -use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Manuxi\SuluEventBundle\Entity\Interfaces\ExcerptTranslationInterface; use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTranslationTrait; +use Manuxi\SuluEventBundle\Repository\EventExcerptTranslationRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event_excerpt_translation") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventExcerptTranslationRepository") - */ +#[ORM\Entity(repositoryClass: EventExcerptTranslationRepository::class)] +#[ORM\Table(name: 'app_event_excerpt_translation')] class EventExcerptTranslation implements ExcerptTranslationInterface { use ExcerptTranslationTrait; - /** - * @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventExcerpt", inversedBy="translations") - * @ORM\JoinColumn(nullable=false) - */ + #[ORM\ManyToOne(targetEntity: EventExcerpt::class, inversedBy: 'translations')] + #[ORM\JoinColumn(nullable: false)] private EventExcerpt $eventExcerpt; public function __construct(EventExcerpt $eventExcerpt, string $locale) diff --git a/src/Entity/EventSeo.php b/src/Entity/EventSeo.php index 3986750..b5b6869 100644 --- a/src/Entity/EventSeo.php +++ b/src/Entity/EventSeo.php @@ -13,30 +13,22 @@ use Manuxi\SuluEventBundle\Entity\Interfaces\SeoTranslatableInterface; use Manuxi\SuluEventBundle\Entity\Traits\SeoTrait; use Manuxi\SuluEventBundle\Entity\Traits\SeoTranslatableTrait; +use Manuxi\SuluEventBundle\Repository\EventSeoRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event_seo") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventSeoRepository") - */ +#[ORM\Entity(repositoryClass: EventSeoRepository::class)] +#[ORM\Table(name: 'app_event_seo')] class EventSeo implements SeoInterface, SeoTranslatableInterface { use SeoTrait; use SeoTranslatableTrait; - /** - * @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Event", inversedBy="eventSeo", cascade={"persist", "remove"}) - * @JoinColumn(name="event_id", referencedColumnName="id", nullable=false) - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToOne(inversedBy: 'eventSeo', targetEntity: Event::class, cascade: ['persist', 'remove'])] + #[ORM\JoinColumn(name: 'event_id', referencedColumnName: "id", nullable: false)] private ?Event $event = null; - /** - * @ORM\OneToMany(targetEntity="EventSeoTranslation", mappedBy="eventSeo", cascade={"ALL"}, indexBy="locale") - * - * @Serializer\Exclude - */ + #[Serializer\Exclude] + #[ORM\OneToMany(mappedBy: 'eventSeo', targetEntity: EventSeoTranslation::class, cascade: ['all'], indexBy: 'locale')] private Collection $translations; public function __construct() diff --git a/src/Entity/EventSeoTranslation.php b/src/Entity/EventSeoTranslation.php index eac0927..33ca80b 100644 --- a/src/Entity/EventSeoTranslation.php +++ b/src/Entity/EventSeoTranslation.php @@ -7,20 +7,16 @@ use Doctrine\ORM\Mapping as ORM; use Manuxi\SuluEventBundle\Entity\Interfaces\SeoTranslationInterface; use Manuxi\SuluEventBundle\Entity\Traits\SeoTranslationTrait; +use Manuxi\SuluEventBundle\Repository\EventSeoTranslationRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event_seo_translation") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventSeoTranslationRepository") - */ +#[ORM\Entity(repositoryClass: EventSeoTranslationRepository::class)] +#[ORM\Table(name: 'app_event_seo_translation')] class EventSeoTranslation implements SeoTranslationInterface { use SeoTranslationTrait; - /** - * @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventSeo", inversedBy="translations") - * @ORM\JoinColumn(nullable=false) - */ + #[ORM\ManyToOne(targetEntity: EventSeo::class, inversedBy: 'translations')] + #[ORM\JoinColumn(nullable: false)] private EventSeo $eventSeo; public function __construct(EventSeo $eventSeo, string $locale) diff --git a/src/Entity/EventSettings.php b/src/Entity/EventSettings.php index f4733de..cf4ee82 100644 --- a/src/Entity/EventSettings.php +++ b/src/Entity/EventSettings.php @@ -2,14 +2,13 @@ namespace Manuxi\SuluEventBundle\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Sulu\Component\Persistence\Model\AuditableInterface; use Sulu\Component\Persistence\Model\AuditableTrait; -/** - * @ORM\Entity() - * @ORM\Table(name="app_event_settings") - */ +#[ORM\Entity()] +#[ORM\Table(name: 'app_event_settings')] class EventSettings implements AuditableInterface { use AuditableTrait; @@ -18,41 +17,27 @@ class EventSettings implements AuditableInterface public const FORM_KEY = 'config'; public const SECURITY_CONTEXT = 'sulu.event.settings'; - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] private ?int $id = null; - /** - * @ORM\Column(type="boolean", nullable=true) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: true)] private ?bool $toggleHeader = null; - /** - * @ORM\Column(type="boolean", nullable=true) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: true)] private ?bool $toggleHero = null; - /** - * @ORM\Column(type="boolean", nullable=true) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: true)] private ?bool $toggleBreadcrumbs = null; - /** - * @ORM\Column(type="string", nullable=true) - */ + #[ORM\Column(type: Types::STRING, nullable: true)] private ?string $pageEvents = null; - /** - * @ORM\Column(type="string", nullable=true) - */ + #[ORM\Column(type: Types::STRING, nullable: true)] private ?string $pageEventsPending = null; - /** - * @ORM\Column(type="string", nullable=true) - */ + #[ORM\Column(type: Types::STRING, nullable: true)] private ?string $pageEventsExpired = null; public function getId(): ?int diff --git a/src/Entity/EventTranslation.php b/src/Entity/EventTranslation.php index 1258bc5..3dc510a 100644 --- a/src/Entity/EventTranslation.php +++ b/src/Entity/EventTranslation.php @@ -4,6 +4,7 @@ namespace Manuxi\SuluEventBundle\Entity; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Manuxi\SuluEventBundle\Entity\Interfaces\AuditableInterface; use Manuxi\SuluEventBundle\Entity\Traits\AuditableTrait; @@ -13,12 +14,10 @@ use Manuxi\SuluEventBundle\Entity\Traits\RouteTrait; use Manuxi\SuluEventBundle\Entity\Traits\ShowAuthorTrait; use Manuxi\SuluEventBundle\Entity\Traits\ShowDateTrait; +use Manuxi\SuluEventBundle\Repository\EventTranslationRepository; -/** - * @ORM\Entity - * @ORM\Table(name="app_event_translation") - * @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventTranslationRepository") - */ +#[ORM\Entity(repositoryClass: EventTranslationRepository::class)] +#[ORM\Table(name: 'app_event_translation')] class EventTranslation implements AuditableInterface { use AuditableTrait; @@ -29,47 +28,31 @@ class EventTranslation implements AuditableInterface use ShowAuthorTrait; use ShowDateTrait; - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] private ?int $id = null; - /** - * @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Event", inversedBy="translations") - * @ORM\JoinColumn(nullable=false) - */ + #[ORM\ManyToOne(targetEntity: Event::class, inversedBy: 'translations')] + #[ORM\JoinColumn(nullable: false)] private Event $event; - /** - * @ORM\Column(type="string", length=5) - */ + #[ORM\Column(type: Types::STRING, length: 5)] private string $locale; - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $title = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $subtitle = null; - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $summary = null; - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $text = null; - /** - * @ORM\Column(type="text", nullable=true) - */ + #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $footer = null; public function __construct(Event $event, string $locale) diff --git a/src/Entity/Interfaces/AuthoredInterface.php b/src/Entity/Interfaces/AuthoredInterface.php index b31526f..d71b926 100644 --- a/src/Entity/Interfaces/AuthoredInterface.php +++ b/src/Entity/Interfaces/AuthoredInterface.php @@ -7,5 +7,5 @@ interface AuthoredInterface { public function getAuthored(): ?\DateTime; - public function setAuthored(\DateTime $authored); + public function setAuthored(?\DateTime $authored); } diff --git a/src/Entity/Interfaces/AuthoredTranslatableInterface.php b/src/Entity/Interfaces/AuthoredTranslatableInterface.php index d075e60..5f9fb85 100644 --- a/src/Entity/Interfaces/AuthoredTranslatableInterface.php +++ b/src/Entity/Interfaces/AuthoredTranslatableInterface.php @@ -7,5 +7,5 @@ interface AuthoredTranslatableInterface { public function getAuthored(): ?\DateTime; - public function setAuthored(\DateTime $authored); + public function setAuthored(?\DateTime $authored); } diff --git a/src/Entity/Location.php b/src/Entity/Location.php index a474f14..b307d9c 100644 --- a/src/Entity/Location.php +++ b/src/Entity/Location.php @@ -4,15 +4,13 @@ namespace Manuxi\SuluEventBundle\Entity; +use Doctrine\DBAL\Types\Types; use Manuxi\SuluEventBundle\Entity\Traits\ImageTrait; use Manuxi\SuluEventBundle\Repository\LocationRepository; use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - * @ORM\Table(name="app_location") - * @ORM\Entity(repositoryClass=LocationRepository::class) - */ +#[ORM\Entity(repositoryClass: LocationRepository::class)] +#[ORM\Table(name: 'app_location')] class Location { public const RESOURCE_KEY = 'locations'; @@ -21,52 +19,34 @@ class Location use ImageTrait; - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="integer") - */ - private $id; - - /** - * @ORM\Column(type="string", length=255) - */ - private $name; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $street; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $number; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $postalCode; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $city; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $state; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $countryCode; - - /** - * @ORM\Column(type="text", nullable=true) - */ - private $notes; + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] + private ?int $id = null; + + #[ORM\Column(type: Types::STRING, length: 255)] + private string $name; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $street; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $number; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $postalCode; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $city; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $state; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $countryCode; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $notes; public function getId(): ?int { @@ -155,7 +135,7 @@ public function getNotes(): ?string return $this->notes; } - public function setNotes($notes): self + public function setNotes(?string $notes): self { $this->notes = $notes; return $this; diff --git a/src/Entity/Models/EventModel.php b/src/Entity/Models/EventModel.php index 9339bfd..efb9c71 100644 --- a/src/Entity/Models/EventModel.php +++ b/src/Entity/Models/EventModel.php @@ -291,11 +291,15 @@ private function mapSettingsToEvent(Event $entity, array $data): Event throw new EntityNotFoundException($this->contactRepository->getClassName(), $authorId); } $entity->setAuthor($author); + } else { + $entity->setAuthor(null); } $authored = $this->getProperty($data, 'authored'); if ($authored) { $entity->setAuthored(new \DateTime($authored)); + } else { + $entity->setAuthored(null); } return $entity; } diff --git a/src/Entity/Traits/ArrayPropertyTrait.php b/src/Entity/Traits/ArrayPropertyTrait.php index 8ccd1b8..b9d93a8 100644 --- a/src/Entity/Traits/ArrayPropertyTrait.php +++ b/src/Entity/Traits/ArrayPropertyTrait.php @@ -6,10 +6,8 @@ trait ArrayPropertyTrait { - /** - * @return mixed|string|null - */ - protected function getProperty(array $data, string $key, string $default = null) + + protected function getProperty(array $data, string $key, ?string $default = null): mixed { if (\array_key_exists($key, $data)) { return $data[$key]; @@ -18,10 +16,7 @@ protected function getProperty(array $data, string $key, string $default = null) return $default; } - /** - * @return mixed|string|null - */ - protected function getPropertyMulti(array $data, array $keys, string $default = null) + protected function getPropertyMulti(array $data, array $keys, ?string $default = null): mixed { $currentKey = array_shift($keys); if(0 === count($keys)){ diff --git a/src/Entity/Traits/AuthorTrait.php b/src/Entity/Traits/AuthorTrait.php index bc55a2a..6c1c9d6 100644 --- a/src/Entity/Traits/AuthorTrait.php +++ b/src/Entity/Traits/AuthorTrait.php @@ -4,11 +4,14 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\ORM\Mapping as ORM; use Sulu\Bundle\ContactBundle\Entity\ContactInterface; trait AuthorTrait { + #[ORM\ManyToOne(targetEntity: ContactInterface::class)] + #[ORM\JoinColumn(onDelete: 'SET NULL')] protected ?ContactInterface $author = null; public function getAuthor(): ?ContactInterface diff --git a/src/Entity/Traits/AuthorTranslatableTrait.php b/src/Entity/Traits/AuthorTranslatableTrait.php index 3f6c5ee..c2343b8 100644 --- a/src/Entity/Traits/AuthorTranslatableTrait.php +++ b/src/Entity/Traits/AuthorTranslatableTrait.php @@ -12,9 +12,7 @@ trait AuthorTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="author") - */ + #[Serializer\VirtualProperty(name: "author")] public function getAuthor(): ?int { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/AuthoredTrait.php b/src/Entity/Traits/AuthoredTrait.php index 2df339b..ccaaa18 100644 --- a/src/Entity/Traits/AuthoredTrait.php +++ b/src/Entity/Traits/AuthoredTrait.php @@ -5,10 +5,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; use DateTime; +use Doctrine\DBAL\Types\Types; +use Doctrine\ORM\Mapping as ORM; trait AuthoredTrait { + #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] protected ?DateTime $authored = null; public function getAuthored(): ?DateTime diff --git a/src/Entity/Traits/AuthoredTranslatableTrait.php b/src/Entity/Traits/AuthoredTranslatableTrait.php index a43c998..d94e136 100644 --- a/src/Entity/Traits/AuthoredTranslatableTrait.php +++ b/src/Entity/Traits/AuthoredTranslatableTrait.php @@ -12,9 +12,7 @@ trait AuthoredTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="authored") - */ + #[Serializer\VirtualProperty(name: "authored")] public function getAuthored(): ?DateTime { $translation = $this->getTranslation($this->getLocale()); @@ -25,7 +23,7 @@ public function getAuthored(): ?DateTime return $translation->getAuthored(); } - public function setAuthored(DateTime $authored): self + public function setAuthored(?DateTime $authored): self { $translation = $this->getTranslation($this->getLocale()); if (!$translation) { diff --git a/src/Entity/Traits/ExcerptTrait.php b/src/Entity/Traits/ExcerptTrait.php index 9ea6167..c052d68 100644 --- a/src/Entity/Traits/ExcerptTrait.php +++ b/src/Entity/Traits/ExcerptTrait.php @@ -4,15 +4,15 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; trait ExcerptTrait { - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] private $id = null; public function getId(): ?int diff --git a/src/Entity/Traits/ExcerptTranslatableTrait.php b/src/Entity/Traits/ExcerptTranslatableTrait.php index 6890132..1031398 100644 --- a/src/Entity/Traits/ExcerptTranslatableTrait.php +++ b/src/Entity/Traits/ExcerptTranslatableTrait.php @@ -27,9 +27,7 @@ public function copyToLocale(string $locale): self return $this; } - /** - * @Serializer\VirtualProperty(name="title") - */ + #[Serializer\VirtualProperty(name: "title")] public function getTitle(): ?string { $translation = $this->getTranslation($this->locale); @@ -49,9 +47,7 @@ public function setTitle(?string $title): self return $this; } - /** - * @Serializer\VirtualProperty(name="more") - */ + #[Serializer\VirtualProperty(name: "more")] public function getMore(): ?string { $translation = $this->getTranslation($this->locale); @@ -71,9 +67,7 @@ public function setMore(?string $more): self return $this; } - /** - * @Serializer\VirtualProperty(name="description") - */ + #[Serializer\VirtualProperty(name: "description")] public function getDescription(): ?string { $translation = $this->getTranslation($this->locale); @@ -105,9 +99,9 @@ public function setLocale(string $locale): self } /** - * @return CategoryInterface[] - * @Serializer\VirtualProperty(name="categories") + * @return ?CategoryInterface[] */ + #[Serializer\VirtualProperty(name: "categories")] public function getCategories(): ?array { $translation = $this->getTranslation($this->locale); @@ -137,9 +131,7 @@ public function removeCategories(): self return $this; } - /** - * @Serializer\VirtualProperty(name="tags") - */ + #[Serializer\VirtualProperty(name: "tags")] public function getTags(): array { $translation = $this->getTranslation($this->locale); @@ -172,8 +164,8 @@ public function removeTags(): self /** * Usually this method should be named getIcons() but since the VirtualProperty annotation seems not to work * properly in traits this method is renamed to match the property (icon) for now. - * @Serializer\VirtualProperty(name="icon") */ + #[Serializer\VirtualProperty(name: "icon")] public function getIcon(): ?array { $translation = $this->getTranslation($this->locale); @@ -203,9 +195,7 @@ public function removeIcons(): self return $this; } - /** - * @Serializer\VirtualProperty(name="images") - */ + #[Serializer\VirtualProperty(name: "images")] public function getImages(): ?array { $translation = $this->getTranslation($this->locale); diff --git a/src/Entity/Traits/ExcerptTranslationTrait.php b/src/Entity/Traits/ExcerptTranslationTrait.php index 8d2e6f2..e1aa6de 100644 --- a/src/Entity/Traits/ExcerptTranslationTrait.php +++ b/src/Entity/Traits/ExcerptTranslationTrait.php @@ -6,82 +6,66 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use Doctrine\ORM\Mapping\InverseJoinColumn; +use Doctrine\ORM\Mapping\JoinColumn; use Doctrine\ORM\Mapping\JoinTable; +use Doctrine\ORM\Mapping\ManyToMany; use JMS\Serializer\Annotation as Serializer; +use Sulu\Bundle\CategoryBundle\Entity\Category; use Sulu\Bundle\CategoryBundle\Entity\CategoryInterface; use Sulu\Bundle\MediaBundle\Entity\MediaInterface; use Sulu\Bundle\TagBundle\Tag\TagInterface; trait ExcerptTranslationTrait { - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ - private $id; - /** - * @ORM\Column(type="string", length=5) - */ - private $locale = 'en'; + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] + private ?int $id = null; - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $title; + #[ORM\Column(type: Types::STRING, length: 5)] + private string $locale = 'de'; - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $more; + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $title = null; - /** - * @ORM\Column(type="text", nullable=true) - */ - private $description; + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $more = null; - /** - * @ORM\ManyToMany(targetEntity="Sulu\Bundle\CategoryBundle\Entity\Category") - * @JoinTable(name="app_event_excerpt_categories", - * joinColumns={@ORM\JoinColumn(name="excerpt_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="category_id", referencedColumnName="id")} - * ) - */ + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $description = null; + + #[ManyToMany(targetEntity: Category::class)] + #[JoinTable(name: 'app_event_excerpt_categories')] + #[JoinColumn(name: "excerpt_id", referencedColumnName: "id")] + #[InverseJoinColumn(name: "category_id", referencedColumnName: "id")] private $categories; - /** - * @ORM\ManyToMany(targetEntity="Sulu\Bundle\TagBundle\Tag\TagInterface") - * @JoinTable(name="app_event_excerpt_tags", - * joinColumns={@ORM\JoinColumn(name="excerpt_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")} - * ) - */ - private $tags; + #[ManyToMany(targetEntity: TagInterface::class)] + #[JoinTable(name: 'app_event_excerpt_tags')] + #[JoinColumn(name: "excerpt_id", referencedColumnName: "id")] + #[InverseJoinColumn(name: "tag_id", referencedColumnName: "id")] + private ?Collection $tags = null; /** * @TODO */ - private $segments; + private ?Collection $segments = null; - /** - * @ORM\ManyToMany(targetEntity="Sulu\Bundle\MediaBundle\Entity\MediaInterface") - * @JoinTable(name="app_event_excerpt_icons", - * joinColumns={@ORM\JoinColumn(name="excerpt_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="icon_id", referencedColumnName="id")} - * ) - */ + #[ManyToMany(targetEntity: MediaInterface::class)] + #[JoinTable(name: 'app_event_excerpt_icons')] + #[JoinColumn(name: "excerpt_id", referencedColumnName: "id")] + #[InverseJoinColumn(name: "icon_id", referencedColumnName: "id")] private $icons; - /** - * @ORM\ManyToMany(targetEntity="Sulu\Bundle\MediaBundle\Entity\MediaInterface") - * @JoinTable(name="app_event_excerpt_images", - * joinColumns={@ORM\JoinColumn(name="excerpt_id", referencedColumnName="id")}, - * inverseJoinColumns={@ORM\JoinColumn(name="image_id", referencedColumnName="id")} - * ) - */ - private $images; + #[ManyToMany(targetEntity: MediaInterface::class)] + #[JoinTable(name: 'app_event_excerpt_images')] + #[JoinColumn(name: "excerpt_id", referencedColumnName: "id")] + #[InverseJoinColumn(name: "image_id", referencedColumnName: "id")] + private ?Collection $images = null; private function initExcerptTranslationTrait(): void { @@ -259,9 +243,7 @@ public function getIcons(): ?Collection return $this->icons; } - /** - * @Serializer\VirtualProperty(name="icon") - */ + #[Serializer\VirtualProperty(name: "icon")] public function getIconIds(): array { $icons = []; diff --git a/src/Entity/Traits/ImageTrait.php b/src/Entity/Traits/ImageTrait.php index e7fc5fb..f64e3aa 100644 --- a/src/Entity/Traits/ImageTrait.php +++ b/src/Entity/Traits/ImageTrait.php @@ -8,10 +8,9 @@ trait ImageTrait { - /** - * @ORM\ManyToOne(targetEntity=MediaInterface::class) - * @Serializer\Exclude() - */ + + #[ORM\ManyToOne(targetEntity: MediaInterface::class)] + #[ORM\JoinColumn(onDelete: 'SET NULL')] private ?MediaInterface $image = null; public function getImage(): ?MediaInterface @@ -19,10 +18,8 @@ public function getImage(): ?MediaInterface return $this->image; } - /** - * @Serializer\VirtualProperty - * @Serializer\SerializedName("image") - */ + #[Serializer\VirtualProperty] + #[Serializer\SerializedName("image")] public function getImageData(): ?array { if ($image = $this->getImage()) { diff --git a/src/Entity/Traits/ImageTranslatableTrait.php b/src/Entity/Traits/ImageTranslatableTrait.php index c38407b..db60c47 100644 --- a/src/Entity/Traits/ImageTranslatableTrait.php +++ b/src/Entity/Traits/ImageTranslatableTrait.php @@ -13,9 +13,7 @@ trait ImageTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="image") - */ + #[Serializer\VirtualProperty(name: "image")] public function getImage(): ?MediaInterface { $translation = $this->getTranslation($this->getLocale()); @@ -26,10 +24,8 @@ public function getImage(): ?MediaInterface return $translation->getImage(); } - /** - * @Serializer\VirtualProperty - * @Serializer\SerializedName("image") - */ + #[Serializer\VirtualProperty] + #[Serializer\SerializedName("image")] public function getImageData(): ?array { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/LinkTrait.php b/src/Entity/Traits/LinkTrait.php index 5d3b5dc..2be8511 100644 --- a/src/Entity/Traits/LinkTrait.php +++ b/src/Entity/Traits/LinkTrait.php @@ -2,15 +2,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; trait LinkTrait { - /** - * @ORM\Column(type="array", nullable=true) - */ + #[ORM\Column(type: Types::JSON, nullable: true)] private ?array $link = null; public function getLink(): ?array diff --git a/src/Entity/Traits/LinkTranslatableTrait.php b/src/Entity/Traits/LinkTranslatableTrait.php index b521883..8c3630c 100644 --- a/src/Entity/Traits/LinkTranslatableTrait.php +++ b/src/Entity/Traits/LinkTranslatableTrait.php @@ -4,7 +4,6 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; -use DateTime; use JMS\Serializer\Annotation as Serializer; trait LinkTranslatableTrait @@ -13,9 +12,7 @@ trait LinkTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="link") - */ + #[Serializer\VirtualProperty(name: 'link')] public function getLink(): ?array { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/PdfTrait.php b/src/Entity/Traits/PdfTrait.php index fc21266..089a093 100644 --- a/src/Entity/Traits/PdfTrait.php +++ b/src/Entity/Traits/PdfTrait.php @@ -9,10 +9,9 @@ trait PdfTrait { - /** - * @ORM\ManyToOne(targetEntity=MediaInterface::class) - * @Serializer\Exclude() - */ + #[ORM\ManyToOne(targetEntity: MediaInterface::class)] + #[ORM\JoinColumn(onDelete: 'SET NULL')] + #[Serializer\Exclude] private ?MediaInterface $pdf = null; public function getPdf(): ?MediaInterface @@ -20,12 +19,8 @@ public function getPdf(): ?MediaInterface return $this->pdf; } - /** - * @return array|null - * - * @Serializer\VirtualProperty - * @Serializer\SerializedName("pdf") - */ + #[Serializer\VirtualProperty] + #[Serializer\SerializedName("pdf")] public function getPdfData(): ?array { if ($pdf = $this->getPdf()) { diff --git a/src/Entity/Traits/PdfTranslatableTrait.php b/src/Entity/Traits/PdfTranslatableTrait.php index 65af784..da6368c 100644 --- a/src/Entity/Traits/PdfTranslatableTrait.php +++ b/src/Entity/Traits/PdfTranslatableTrait.php @@ -13,9 +13,7 @@ trait PdfTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="pdf") - */ + #[Serializer\Exclude] public function getPdf(): ?MediaInterface { $translation = $this->getTranslation($this->getLocale()); @@ -26,10 +24,8 @@ public function getPdf(): ?MediaInterface return $translation->getPdf(); } - /** - * @Serializer\VirtualProperty - * @Serializer\SerializedName("pdf") - */ + #[Serializer\VirtualProperty] + #[Serializer\SerializedName("pdf")] public function getPdfData(): ?array { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/RouteTrait.php b/src/Entity/Traits/RouteTrait.php index b4caf11..93c2762 100644 --- a/src/Entity/Traits/RouteTrait.php +++ b/src/Entity/Traits/RouteTrait.php @@ -2,15 +2,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; -use Sulu\Bundle\MediaBundle\Entity\MediaInterface; trait RouteTrait { - /** - * @ORM\Column(type="string", length=255) - */ + + #[ORM\Column(type: Types::STRING, length: 255)] private string $routePath; public function getRoutePath(): string diff --git a/src/Entity/Traits/RouteTranslatableTrait.php b/src/Entity/Traits/RouteTranslatableTrait.php index 976cd2a..8464c32 100644 --- a/src/Entity/Traits/RouteTranslatableTrait.php +++ b/src/Entity/Traits/RouteTranslatableTrait.php @@ -11,9 +11,7 @@ trait RouteTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="route_path") - */ + #[Serializer\VirtualProperty(name: "route_path")] public function getRoutePath(): ?string { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/SeoTrait.php b/src/Entity/Traits/SeoTrait.php index 630ed92..5224f25 100644 --- a/src/Entity/Traits/SeoTrait.php +++ b/src/Entity/Traits/SeoTrait.php @@ -4,31 +4,25 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; trait SeoTrait { - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ - private $id = null; - - /** - * @ORM\Column(type="boolean") - */ - private $hideInSitemap = false; - - /** - * @ORM\Column(type="boolean") - */ - private $noFollow = false; - - /** - * @ORM\Column(type="boolean") - */ - private $noIndex = false; + + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] + private ?int $id = null; + + #[ORM\Column(type: Types::BOOLEAN)] + private bool $hideInSitemap = false; + + #[ORM\Column(type: Types::BOOLEAN)] + private bool $noFollow = false; + + #[ORM\Column(type: Types::BOOLEAN)] + private bool $noIndex = false; public function getId(): ?int { diff --git a/src/Entity/Traits/SeoTranslatableTrait.php b/src/Entity/Traits/SeoTranslatableTrait.php index 9de1bb1..8af7a86 100644 --- a/src/Entity/Traits/SeoTranslatableTrait.php +++ b/src/Entity/Traits/SeoTranslatableTrait.php @@ -8,7 +8,7 @@ trait SeoTranslatableTrait { - private $locale = 'en'; + private string $locale = 'en'; abstract protected function getTranslation(string $locale); abstract protected function createTranslation(string $locale); @@ -24,9 +24,7 @@ public function copyToLocale(string $locale): self return $this; } - /** - * @Serializer\VirtualProperty(name="title") - */ + #[Serializer\VirtualProperty(name: "title")] public function getTitle(): ?string { $translation = $this->getTranslation($this->locale); @@ -49,9 +47,7 @@ public function setTitle(?string $title): self return $this; } - /** - * @Serializer\VirtualProperty(name="keywords") - */ + #[Serializer\VirtualProperty(name: "keywords")] public function getKeywords(): ?string { $translation = $this->getTranslation($this->locale); @@ -74,9 +70,7 @@ public function setKeywords(?string $keywords): self return $this; } - /** - * @Serializer\VirtualProperty(name="canonicalUrl") - */ + #[Serializer\VirtualProperty(name: "canonicalUrl")] public function getCanonicalUrl(): ?string { $translation = $this->getTranslation($this->locale); @@ -99,9 +93,7 @@ public function setCanonicalUrl(?string $canonicalUrl): self return $this; } - /** - * @Serializer\VirtualProperty(name="description") - */ + #[Serializer\VirtualProperty(name: "description")] public function getDescription(): ?string { $translation = $this->getTranslation($this->locale); diff --git a/src/Entity/Traits/SeoTranslationTrait.php b/src/Entity/Traits/SeoTranslationTrait.php index ac80b15..f13baac 100644 --- a/src/Entity/Traits/SeoTranslationTrait.php +++ b/src/Entity/Traits/SeoTranslationTrait.php @@ -4,41 +4,30 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; trait SeoTranslationTrait { - /** - * @ORM\Id() - * @ORM\GeneratedValue() - * @ORM\Column(type="integer") - */ - private $id; - - /** - * @ORM\Column(type="string", length=5) - */ - private $locale; - - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ - private $title; - - /** - * @ORM\Column(type="text", nullable=true) - */ - private $canonicalUrl; - - /** - * @ORM\Column(type="text", nullable=true) - */ - private $keywords; - - /** - * @ORM\Column(type="text", nullable=true) - */ - private $description; + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: Types::INTEGER)] + private int $id; + + #[ORM\Column(type: Types::STRING, length: 5)] + private ?string $locale = null; + + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] + private ?string $title = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $canonicalUrl = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $keywords = null; + + #[ORM\Column(type: Types::TEXT, nullable: true)] + private ?string $description = null; public function getId(): ?int { diff --git a/src/Entity/Traits/ShowAuthorTrait.php b/src/Entity/Traits/ShowAuthorTrait.php index 53eceac..403d769 100644 --- a/src/Entity/Traits/ShowAuthorTrait.php +++ b/src/Entity/Traits/ShowAuthorTrait.php @@ -4,14 +4,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; trait ShowAuthorTrait { - /** - * @ORM\Column(type="boolean", nullable=true) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: true)] private ?bool $showAuthor = null; public function getShowAuthor(): bool diff --git a/src/Entity/Traits/ShowAuthorTranslatableTrait.php b/src/Entity/Traits/ShowAuthorTranslatableTrait.php index 0570b15..f8a5718 100644 --- a/src/Entity/Traits/ShowAuthorTranslatableTrait.php +++ b/src/Entity/Traits/ShowAuthorTranslatableTrait.php @@ -11,9 +11,7 @@ trait ShowAuthorTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="show_author") - */ + #[Serializer\VirtualProperty(name: "show_author")] public function getShowAuthor(): ?bool { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/ShowDateTrait.php b/src/Entity/Traits/ShowDateTrait.php index 84965b4..08b6110 100644 --- a/src/Entity/Traits/ShowDateTrait.php +++ b/src/Entity/Traits/ShowDateTrait.php @@ -4,14 +4,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; trait ShowDateTrait { - /** - * @ORM\Column(type="boolean", nullable=true) - */ + #[ORM\Column(type: Types::BOOLEAN, nullable: true)] private ?bool $showDate = null; public function getShowDate(): bool diff --git a/src/Entity/Traits/ShowDateTranslatableTrait.php b/src/Entity/Traits/ShowDateTranslatableTrait.php index ccf1903..0ff02b2 100644 --- a/src/Entity/Traits/ShowDateTranslatableTrait.php +++ b/src/Entity/Traits/ShowDateTranslatableTrait.php @@ -11,9 +11,7 @@ trait ShowDateTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="show_date") - */ + #[Serializer\VirtualProperty(name: "show_date")] public function getShowDate(): ?bool { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/TimestampableTranslatableTrait.php b/src/Entity/Traits/TimestampableTranslatableTrait.php index f653799..7538ded 100644 --- a/src/Entity/Traits/TimestampableTranslatableTrait.php +++ b/src/Entity/Traits/TimestampableTranslatableTrait.php @@ -11,9 +11,7 @@ trait TimestampableTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="created") - */ + #[Serializer\VirtualProperty(name: "created")] public function getCreated(): ?\DateTime { $translation = $this->getTranslation($this->getLocale()); @@ -24,9 +22,7 @@ public function getCreated(): ?\DateTime return $translation->getCreated(); } - /** - * @Serializer\VirtualProperty(name="changed") - */ + #[Serializer\VirtualProperty(name: "changed")] public function getChanged(): ?\DateTime { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/UrlTrait.php b/src/Entity/Traits/UrlTrait.php index 173c86f..18d5d9d 100644 --- a/src/Entity/Traits/UrlTrait.php +++ b/src/Entity/Traits/UrlTrait.php @@ -2,15 +2,13 @@ namespace Manuxi\SuluEventBundle\Entity\Traits; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use JMS\Serializer\Annotation as Serializer; trait UrlTrait { - /** - * @ORM\Column(type="string", length=255, nullable=true) - */ + #[ORM\Column(type: Types::STRING, length: 255, nullable: true)] private ?string $url = null; public function getUrl(): ?string diff --git a/src/Entity/Traits/UrlTranslatableTrait.php b/src/Entity/Traits/UrlTranslatableTrait.php index 422c6a7..f63caa9 100644 --- a/src/Entity/Traits/UrlTranslatableTrait.php +++ b/src/Entity/Traits/UrlTranslatableTrait.php @@ -13,9 +13,7 @@ trait UrlTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="url") - */ + #[Serializer\VirtualProperty(name: "url")] public function getUrl(): ?string { $translation = $this->getTranslation($this->getLocale()); diff --git a/src/Entity/Traits/UserBlameTranslatableTrait.php b/src/Entity/Traits/UserBlameTranslatableTrait.php index 744b6d2..609f722 100644 --- a/src/Entity/Traits/UserBlameTranslatableTrait.php +++ b/src/Entity/Traits/UserBlameTranslatableTrait.php @@ -11,9 +11,7 @@ trait UserBlameTranslatableTrait abstract public function getLocale(); abstract protected function getTranslation(string $locale); - /** - * @Serializer\VirtualProperty(name="creator") - */ + #[Serializer\VirtualProperty(name: "creator")] public function getCreator(): ?int { $translation = $this->getTranslation($this->getLocale()); @@ -24,9 +22,7 @@ public function getCreator(): ?int return $translation->getCreator()->getId(); } - /** - * @Serializer\VirtualProperty(name="changer") - */ + #[Serializer\VirtualProperty(name: "changer")] public function getChanger(): ?int { $translation = $this->getTranslation($this->getLocale());