Skip to content

Commit 23fbc5b

Browse files
author
Manuel Bertrams
committed
Symfony 7.*, Orm annotations
1 parent 9b3676c commit 23fbc5b

39 files changed

+262
-475
lines changed

composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
],
1919
"require": {
2020
"php": "^8.1",
21+
"doctrine/doctrine-bundle": "^2.12",
2122
"phpcr/phpcr-migrations-bundle": "^1.6",
2223
"sulu/sulu": "^2.5",
2324
"sulu/automation-bundle": "^2.1",
@@ -28,8 +29,7 @@
2829
"symfony/http-kernel": "^6.2 | ^7.0",
2930
"symfony/intl": "^6.2 | ^7.0",
3031
"symfony/translation": "^6.2 | ^7.0",
31-
"symfony/security-core": "^6.2 | ^7.0",
32-
"doctrine/doctrine-bundle": "^2.11"
32+
"symfony/security-core": "^6.2 | ^7.0"
3333
},
3434
"require-dev": {
3535
"jackalope/jackalope-doctrine-dbal": "^1.3.4",

src/Entity/Event.php

+30-71
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\Common\Collections\ArrayCollection;
88
use Doctrine\Common\Collections\Collection;
9+
use Doctrine\DBAL\Types\Types;
910
use Doctrine\ORM\Mapping as ORM;
1011
use JMS\Serializer\Annotation as Serializer;
1112
use Manuxi\SuluEventBundle\Entity\Interfaces\AuditableTranslatableInterface;
@@ -16,12 +17,10 @@
1617
use Manuxi\SuluEventBundle\Entity\Traits\RouteTranslatableTrait;
1718
use Manuxi\SuluEventBundle\Entity\Traits\ShowAuthorTranslatableTrait;
1819
use Manuxi\SuluEventBundle\Entity\Traits\ShowDateTranslatableTrait;
20+
use Manuxi\SuluEventBundle\Repository\EventRepository;
1921

20-
/**
21-
* @ORM\Entity
22-
* @ORM\Table(name="app_event")
23-
* @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventRepository")
24-
*/
22+
#[ORM\Entity(repositoryClass: EventRepository::class)]
23+
#[ORM\Table(name: 'app_event')]
2524
class Event implements AuditableTranslatableInterface
2625
{
2726
public const RESOURCE_KEY = 'events';
@@ -36,68 +35,44 @@ class Event implements AuditableTranslatableInterface
3635
use ImageTranslatableTrait;
3736
use ShowAuthorTranslatableTrait;
3837
use ShowDateTranslatableTrait;
39-
/**
40-
* @ORM\Id()
41-
* @ORM\GeneratedValue()
42-
* @ORM\Column(type="integer")
43-
*/
38+
39+
#[ORM\Id]
40+
#[ORM\GeneratedValue]
41+
#[ORM\Column(type: Types::INTEGER)]
4442
private ?int $id = null;
4543

46-
/**
47-
* @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventSeo", mappedBy="event", cascade={"persist", "remove"})
48-
*
49-
* @Serializer\Exclude
50-
*/
44+
#[Serializer\Exclude]
45+
#[ORM\OneToOne(mappedBy: 'event', targetEntity: EventSeo::class, cascade: ['persist', 'remove'])]
5146
private ?EventSeo $eventSeo = null;
5247

53-
/**
54-
* @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventExcerpt", mappedBy="event", cascade={"persist", "remove"})
55-
*
56-
* @Serializer\Exclude
57-
*/
48+
#[Serializer\Exclude]
49+
#[ORM\OneToOne(mappedBy: 'event', targetEntity: EventExcerpt::class, cascade: ['persist', 'remove'])]
5850
private ?EventExcerpt $eventExcerpt = null;
5951

60-
/**
61-
* @ORM\Column(type="boolean", nullable=false)
62-
*/
52+
#[ORM\Column(type: Types::BOOLEAN, nullable: false)]
6353
private bool $enabled;
6454

65-
/**
66-
* @ORM\Column(type="datetime_immutable", nullable=true)
67-
*/
55+
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
6856
private ?\DateTimeImmutable $startDate = null;
6957

70-
/**
71-
* @ORM\Column(type="datetime_immutable", nullable=true)
72-
*/
58+
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
7359
private ?\DateTimeImmutable $endDate = null;
7460

75-
/**
76-
* @ORM\Column(type="string", length=255, nullable=true)
77-
*/
61+
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
7862
private ?string $email = null;
7963

80-
/**
81-
* @ORM\Column(type="string", nullable=true)
82-
*/
64+
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
8365
private ?string $phoneNumber = null;
8466

85-
/**
86-
* @ORM\Column(type="json", nullable=true)
87-
*/
67+
#[ORM\Column(type: Types::JSON, nullable: true)]
8868
private ?array $images = null;
8969

90-
/**
91-
* @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Location")
92-
* @ORM\JoinColumn(onDelete="SET NULL")
93-
*/
70+
#[ORM\ManyToOne(targetEntity: Location::class)]
71+
#[ORM\JoinColumn(onDelete: 'SET NULL')]
9472
private ?Location $location = null;
9573

96-
/**
97-
* @var Collection<string, EventTranslation>
98-
* @ORM\OneToMany(targetEntity="Manuxi\SuluEventBundle\Entity\EventTranslation", mappedBy="event", cascade={"ALL"}, indexBy="locale", fetch="EXTRA_LAZY")
99-
* @Serializer\Exclude
100-
*/
74+
#[Serializer\Exclude]
75+
#[ORM\OneToMany(mappedBy: 'event', targetEntity: EventTranslation::class, cascade: ['all'], fetch: 'EXTRA_LAZY', indexBy: 'locale')]
10176
private Collection $translations;
10277

10378
private string $locale = 'de';
@@ -172,9 +147,7 @@ public function setLocation(?Location $location): self
172147
return $this;
173148
}
174149

175-
/**
176-
* @Serializer\VirtualProperty
177-
*/
150+
#[Serializer\VirtualProperty]
178151
public function getLocationId(): ?int
179152
{
180153
if (!$this->location) {
@@ -184,9 +157,7 @@ public function getLocationId(): ?int
184157
return $this->location->getId();
185158
}
186159

187-
/**
188-
* @Serializer\VirtualProperty(name="title")
189-
*/
160+
#[Serializer\VirtualProperty(name: "title")]
190161
public function getTitle(): ?string
191162
{
192163
$translation = $this->getTranslation($this->locale);
@@ -208,9 +179,7 @@ public function setTitle(string $title): self
208179
return $this;
209180
}
210181

211-
/**
212-
* @Serializer\VirtualProperty(name="subtitle")
213-
*/
182+
#[Serializer\VirtualProperty(name: "subtitle")]
214183
public function getSubtitle(): ?string
215184
{
216185
$translation = $this->getTranslation($this->locale);
@@ -232,9 +201,7 @@ public function setSubtitle(?string $subtitle): self
232201
return $this;
233202
}
234203

235-
/**
236-
* @Serializer\VirtualProperty(name="summary")
237-
*/
204+
#[Serializer\VirtualProperty(name: "summary")]
238205
public function getSummary(): ?string
239206
{
240207
$translation = $this->getTranslation($this->locale);
@@ -256,9 +223,7 @@ public function setSummary(?string $summary): self
256223
return $this;
257224
}
258225

259-
/**
260-
* @Serializer\VirtualProperty(name="text")
261-
*/
226+
#[Serializer\VirtualProperty(name: "text")]
262227
public function getText(): ?string
263228
{
264229
$translation = $this->getTranslation($this->locale);
@@ -280,9 +245,7 @@ public function setText(string $text): self
280245
return $this;
281246
}
282247

283-
/**
284-
* @Serializer\VirtualProperty(name="footer")
285-
*/
248+
#[Serializer\VirtualProperty(name: "footer")]
286249
public function getFooter(): ?string
287250
{
288251
$translation = $this->getTranslation($this->locale);
@@ -336,9 +299,7 @@ public function setEventExcerpt(?EventExcerpt $eventExcerpt): self
336299
return $this;
337300
}
338301

339-
/**
340-
* @Serializer\VirtualProperty(name="ext")
341-
*/
302+
#[Serializer\VirtualProperty(name: "ext")]
342303
public function getExt(): array
343304
{
344305
return $this->ext;
@@ -407,9 +368,7 @@ private function initExt(): self
407368
return $this;
408369
}
409370

410-
/**
411-
* @Serializer\VirtualProperty("availableLocales")
412-
*/
371+
#[Serializer\VirtualProperty(name: "availableLocales")]
413372
public function getAvailableLocales(): array
414373
{
415374
return \array_values($this->translations->getKeys());

src/Entity/EventExcerpt.php

+8-16
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,22 @@
1313
use Manuxi\SuluEventBundle\Entity\Interfaces\ExcerptTranslatableInterface;
1414
use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTrait;
1515
use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTranslatableTrait;
16+
use Manuxi\SuluEventBundle\Repository\EventExcerptRepository;
1617

17-
/**
18-
* @ORM\Entity
19-
* @ORM\Table(name="app_event_excerpt")
20-
* @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventExcerptRepository")
21-
*/
18+
#[ORM\Entity(repositoryClass: EventExcerptRepository::class)]
19+
#[ORM\Table(name: 'app_event_excerpt')]
2220
class EventExcerpt implements ExcerptInterface, ExcerptTranslatableInterface
2321
{
2422
use ExcerptTrait;
2523
use ExcerptTranslatableTrait;
2624

27-
/**
28-
* @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Event", inversedBy="eventExcerpt", cascade={"persist", "remove"})
29-
* @JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
30-
*
31-
* @Serializer\Exclude
32-
*/
25+
#[Serializer\Exclude]
26+
#[ORM\OneToOne(inversedBy: 'eventExcerpt', targetEntity: Event::class, cascade: ['persist', 'remove'])]
27+
#[ORM\JoinColumn(name: 'event_id', referencedColumnName: "id", nullable: false)]
3328
private ?Event $event = null;
3429

35-
/**
36-
* @ORM\OneToMany(targetEntity="EventExcerptTranslation", mappedBy="eventExcerpt", cascade={"ALL"}, indexBy="locale")
37-
*
38-
* @Serializer\Exclude
39-
*/
30+
#[Serializer\Exclude]
31+
#[ORM\OneToMany(mappedBy: 'eventExcerpt', targetEntity: EventExcerptTranslation::class, cascade: ['all'], indexBy: 'locale')]
4032
private Collection $translations;
4133

4234
public function __construct()

src/Entity/EventExcerptTranslation.php

+5-10
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,19 @@
44

55
namespace Manuxi\SuluEventBundle\Entity;
66

7-
use Doctrine\Common\Collections\ArrayCollection;
87
use Doctrine\ORM\Mapping as ORM;
98
use Manuxi\SuluEventBundle\Entity\Interfaces\ExcerptTranslationInterface;
109
use Manuxi\SuluEventBundle\Entity\Traits\ExcerptTranslationTrait;
10+
use Manuxi\SuluEventBundle\Repository\EventExcerptTranslationRepository;
1111

12-
/**
13-
* @ORM\Entity
14-
* @ORM\Table(name="app_event_excerpt_translation")
15-
* @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventExcerptTranslationRepository")
16-
*/
12+
#[ORM\Entity(repositoryClass: EventExcerptTranslationRepository::class)]
13+
#[ORM\Table(name: 'app_event_excerpt_translation')]
1714
class EventExcerptTranslation implements ExcerptTranslationInterface
1815
{
1916
use ExcerptTranslationTrait;
2017

21-
/**
22-
* @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventExcerpt", inversedBy="translations")
23-
* @ORM\JoinColumn(nullable=false)
24-
*/
18+
#[ORM\ManyToOne(targetEntity: EventExcerpt::class, inversedBy: 'translations')]
19+
#[ORM\JoinColumn(nullable: false)]
2520
private EventExcerpt $eventExcerpt;
2621

2722
public function __construct(EventExcerpt $eventExcerpt, string $locale)

src/Entity/EventSeo.php

+8-16
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,22 @@
1313
use Manuxi\SuluEventBundle\Entity\Interfaces\SeoTranslatableInterface;
1414
use Manuxi\SuluEventBundle\Entity\Traits\SeoTrait;
1515
use Manuxi\SuluEventBundle\Entity\Traits\SeoTranslatableTrait;
16+
use Manuxi\SuluEventBundle\Repository\EventSeoRepository;
1617

17-
/**
18-
* @ORM\Entity
19-
* @ORM\Table(name="app_event_seo")
20-
* @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventSeoRepository")
21-
*/
18+
#[ORM\Entity(repositoryClass: EventSeoRepository::class)]
19+
#[ORM\Table(name: 'app_event_seo')]
2220
class EventSeo implements SeoInterface, SeoTranslatableInterface
2321
{
2422
use SeoTrait;
2523
use SeoTranslatableTrait;
2624

27-
/**
28-
* @ORM\OneToOne(targetEntity="Manuxi\SuluEventBundle\Entity\Event", inversedBy="eventSeo", cascade={"persist", "remove"})
29-
* @JoinColumn(name="event_id", referencedColumnName="id", nullable=false)
30-
*
31-
* @Serializer\Exclude
32-
*/
25+
#[Serializer\Exclude]
26+
#[ORM\OneToOne(inversedBy: 'eventSeo', targetEntity: Event::class, cascade: ['persist', 'remove'])]
27+
#[ORM\JoinColumn(name: 'event_id', referencedColumnName: "id", nullable: false)]
3328
private ?Event $event = null;
3429

35-
/**
36-
* @ORM\OneToMany(targetEntity="EventSeoTranslation", mappedBy="eventSeo", cascade={"ALL"}, indexBy="locale")
37-
*
38-
* @Serializer\Exclude
39-
*/
30+
#[Serializer\Exclude]
31+
#[ORM\OneToMany(mappedBy: 'eventSeo', targetEntity: EventSeoTranslation::class, cascade: ['all'], indexBy: 'locale')]
4032
private Collection $translations;
4133

4234
public function __construct()

src/Entity/EventSeoTranslation.php

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,16 @@
77
use Doctrine\ORM\Mapping as ORM;
88
use Manuxi\SuluEventBundle\Entity\Interfaces\SeoTranslationInterface;
99
use Manuxi\SuluEventBundle\Entity\Traits\SeoTranslationTrait;
10+
use Manuxi\SuluEventBundle\Repository\EventSeoTranslationRepository;
1011

11-
/**
12-
* @ORM\Entity
13-
* @ORM\Table(name="app_event_seo_translation")
14-
* @ORM\Entity(repositoryClass="Manuxi\SuluEventBundle\Repository\EventSeoTranslationRepository")
15-
*/
12+
#[ORM\Entity(repositoryClass: EventSeoTranslationRepository::class)]
13+
#[ORM\Table(name: 'app_event_seo_translation')]
1614
class EventSeoTranslation implements SeoTranslationInterface
1715
{
1816
use SeoTranslationTrait;
1917

20-
/**
21-
* @ORM\ManyToOne(targetEntity="Manuxi\SuluEventBundle\Entity\EventSeo", inversedBy="translations")
22-
* @ORM\JoinColumn(nullable=false)
23-
*/
18+
#[ORM\ManyToOne(targetEntity: EventSeo::class, inversedBy: 'translations')]
19+
#[ORM\JoinColumn(nullable: false)]
2420
private EventSeo $eventSeo;
2521

2622
public function __construct(EventSeo $eventSeo, string $locale)

0 commit comments

Comments
 (0)