Skip to content

Commit c323a9c

Browse files
committed
ISSUE-337: use symfony 6.4
1 parent 25706be commit c323a9c

File tree

7 files changed

+55
-21
lines changed

7 files changed

+55
-21
lines changed

composer.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,24 @@
3838
"doctrine/orm": "^2.11",
3939
"doctrine/common": "^3.3",
4040
"doctrine/doctrine-bundle": "^2.7",
41-
"symfony/symfony": "^4.4|^5.4",
42-
"symfony/monolog-bundle": "^3.8|^4.0",
43-
"symfony/dependency-injection": "^4.4|^5.4",
44-
"symfony/config": "^4.4|^5.4",
45-
"symfony/yaml": "^4.4|^5.4",
41+
"symfony/symfony": "^6.4",
42+
"symfony/dependency-injection": "^6.4",
43+
"symfony/config": "^6.4",
44+
"symfony/yaml": "^6.4",
4645
"doctrine/annotations": "*",
4746
"symfony/error-handler": "*",
4847
"symfony/serializer": "*",
49-
"monolog/monolog": "^2.0"
48+
"symfony/monolog-bundle": "^3.10",
49+
"symfony/serializer-pack": "^1.3"
5050
},
5151
"require-dev": {
5252
"phpunit/phpunit": "^9.5.2",
5353
"guzzlehttp/guzzle": "^6.3.0",
5454
"squizlabs/php_codesniffer": "^3.2.0",
55-
"phpstan/phpstan": "^0.7.0|0.12.57",
56-
"nette/caching": "^2.5.0|^3.0.0",
55+
"phpstan/phpstan": "^0.12.57",
56+
"nette/caching": "^3.0.0",
5757
"nikic/php-parser": "^4.19.1",
5858
"phpmd/phpmd": "^2.6.0",
59-
"composer/composer": "^1.6.0",
6059
"doctrine/instantiator": "^1.0.5",
6160
"doctrine/doctrine-fixtures-bundle": "^3.6"
6261
},
@@ -115,7 +114,7 @@
115114
"routes": {
116115
"homepage": {
117116
"resource": "@EmptyStartPageBundle/Controller/",
118-
"type": "annotation"
117+
"type": "attribute"
119118
}
120119
}
121120
}

config/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ framework:
3333
log: true
3434
serializer:
3535
enabled: true
36+
enable_attributes: true
3637

3738
# Doctrine Configuration
3839
doctrine:

src/Domain/Model/Messaging/SubscriberList.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use PhpList\Core\Domain\Model\Traits\CreationDateTrait;
1919
use PhpList\Core\Domain\Model\Traits\IdentityTrait;
2020
use PhpList\Core\Domain\Model\Traits\ModificationDateTrait;
21+
use Symfony\Component\Serializer\Attribute\Groups;
22+
use Symfony\Component\Serializer\Attribute\MaxDepth;
2123

2224
/**
2325
* This class represents an administrator who can log to the system, is allowed to administer
@@ -35,14 +37,17 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio
3537

3638
#[ORM\Column]
3739
#[SerializedName("name")]
40+
#[Groups(['SubscriberList'])]
3841
private string $name = '';
3942

4043
#[ORM\Column]
4144
#[SerializedName("description")]
45+
#[Groups(['SubscriberList'])]
4246
private string $description = '';
4347

4448
#[ORM\Column(name: "entered", type: "datetime", nullable: true)]
4549
#[SerializedName("creation_date")]
50+
#[Groups(['SubscriberList'])]
4651
protected ?DateTime $creationDate = null;
4752

4853
#[ORM\Column(name: "modified", type: "datetime")]
@@ -51,11 +56,13 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio
5156

5257
#[ORM\Column(name: "listorder", type: "integer")]
5358
#[SerializedName("list_position")]
54-
private int $listPosition = 0;
59+
#[Groups(['SubscriberList'])]
60+
private ?int $listPosition;
5561

5662
#[ORM\Column(name: "prefix")]
5763
#[SerializedName("subject_prefix")]
58-
private string $subjectPrefix = '';
64+
#[Groups(['SubscriberList'])]
65+
private ?string $subjectPrefix;
5966

6067
#[ORM\Column(name: "active", type: "boolean")]
6168
#[SerializedName("public")]
@@ -75,6 +82,7 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio
7582
targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscription",
7683
cascade: ["remove"]
7784
)]
85+
#[MaxDepth(1)]
7886
private Collection $subscriptions;
7987

8088
#[ORM\ManyToMany(
@@ -87,6 +95,7 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio
8795
joinColumns: [new ORM\JoinColumn(name: "listid")],
8896
inverseJoinColumns: [new ORM\JoinColumn(name: "userid")]
8997
)]
98+
#[MaxDepth(1)]
9099
private Collection $subscribers;
91100

92101
public function __construct()
@@ -117,7 +126,7 @@ public function setDescription(string $description): void
117126

118127
public function getListPosition(): int
119128
{
120-
return $this->listPosition;
129+
return $this->listPosition ?? 0;
121130
}
122131

123132
public function setListPosition(int $listPosition): void
@@ -127,7 +136,7 @@ public function setListPosition(int $listPosition): void
127136

128137
public function getSubjectPrefix(): string
129138
{
130-
return $this->subjectPrefix;
139+
return $this->subjectPrefix ?? '';
131140
}
132141

133142
public function setSubjectPrefix(string $subjectPrefix): void
@@ -137,7 +146,7 @@ public function setSubjectPrefix(string $subjectPrefix): void
137146

138147
public function isPublic(): bool
139148
{
140-
return $this->public;
149+
return $this->public ?? false;
141150
}
142151

143152
public function setPublic(bool $public): void
@@ -147,7 +156,7 @@ public function setPublic(bool $public): void
147156

148157
public function getCategory(): string
149158
{
150-
return $this->category;
159+
return $this->category ?? '';
151160
}
152161

153162
public function setCategory(string $category): void

src/Domain/Model/Subscription/Subscriber.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use PhpList\Core\Domain\Model\Traits\CreationDateTrait;
1818
use PhpList\Core\Domain\Model\Traits\IdentityTrait;
1919
use PhpList\Core\Domain\Model\Traits\ModificationDateTrait;
20+
use Symfony\Component\Serializer\Attribute\Groups;
2021

2122
/**
2223
* This class represents subscriber who can subscribe to multiple subscriber lists and can receive email messages from
@@ -34,6 +35,7 @@ class Subscriber implements DomainModel, Identity, CreationDate, ModificationDat
3435

3536
#[ORM\Column(name: "entered", type: "datetime", nullable: true)]
3637
#[SerializedName("creation_date")]
38+
#[Groups(['SubscriberListMembers'])]
3739
protected ?DateTime $creationDate = null;
3840

3941
#[ORM\Column(name: "modified", type: "datetime")]
@@ -42,35 +44,42 @@ class Subscriber implements DomainModel, Identity, CreationDate, ModificationDat
4244

4345
#[ORM\Column(unique: true)]
4446
#[SerializedName("email")]
47+
#[Groups(['SubscriberListMembers'])]
4548
private string $email = '';
4649

4750
#[ORM\Column(type: "boolean")]
4851
#[SerializedName("confirmed")]
52+
#[Groups(['SubscriberListMembers'])]
4953
private bool $confirmed = false;
5054

5155
#[ORM\Column(type: "boolean")]
5256
#[SerializedName("blacklisted")]
57+
#[Groups(['SubscriberListMembers'])]
5358
private bool $blacklisted = false;
5459

5560
#[ORM\Column(name: "bouncecount", type: "integer")]
5661
#[SerializedName("bounce_count")]
62+
#[Groups(['SubscriberListMembers'])]
5763
private int $bounceCount = 0;
5864

5965
#[ORM\Column(name: "uniqid", unique: true)]
6066
#[SerializedName("unique_id")]
67+
#[Groups(['SubscriberListMembers'])]
6168
private string $uniqueId = '';
6269

6370
#[ORM\Column(name: "htmlemail", type: "boolean")]
6471
#[SerializedName("html_email")]
72+
#[Groups(['SubscriberListMembers'])]
6573
private bool $htmlEmail = false;
6674

6775
#[ORM\Column(type: "boolean")]
6876
#[SerializedName("disabled")]
77+
#[Groups(['SubscriberListMembers'])]
6978
private bool $disabled = false;
7079

7180
#[ORM\Column(name: "extradata", type: "text")]
7281
#[SerializedName("extra_data")]
73-
private string $extraData = '';
82+
private ?string $extraData;
7483

7584
#[ORM\OneToMany(
7685
mappedBy: "subscriber",
@@ -179,7 +188,7 @@ public function setDisabled(bool $disabled): void
179188

180189
public function getExtraData(): string
181190
{
182-
return $this->extraData;
191+
return $this->extraData ?? '';
183192
}
184193

185194
public function setExtraData(string $extraData): void

src/Domain/Model/Traits/IdentityTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Doctrine\ORM\Mapping as ORM;
88
use Symfony\Component\Serializer\Annotation\SerializedName;
9+
use Symfony\Component\Serializer\Attribute\Groups;
910

1011
/**
1112
* This trait provides an ID property to domain models.
@@ -20,6 +21,7 @@ trait IdentityTrait
2021
#[ORM\Column(type: "integer")]
2122
#[ORM\GeneratedValue]
2223
#[SerializedName("id")]
24+
#[Groups(['SubscriberList'])]
2325
private int $id;
2426

2527
public function getId(): int

src/Domain/Repository/Subscription/SubscriberRepository.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,19 @@
1616
*/
1717
class SubscriberRepository extends AbstractRepository
1818
{
19+
/**
20+
* Get subscribers by subscribed lists.
21+
*
22+
* @param int $listId The ID of the subscription list.
23+
* @return Subscriber[] Returns an array of Subscriber entities.
24+
*/
25+
public function findSubscribersBySubscribedList(int $listId): array
26+
{
27+
return $this->createQueryBuilder('s')
28+
->innerJoin('s.subscribedLists', 'l')
29+
->where('l.id = :listId')
30+
->setParameter('listId', $listId)
31+
->getQuery()
32+
->getResult();
33+
}
1934
}

src/EmptyStartPageBundle/Controller/DefaultController.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace PhpList\Core\EmptyStartPageBundle\Controller;
66

77
use InvalidArgumentException;
8-
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
98
use Symfony\Component\HttpFoundation\Response;
109
use Symfony\Component\Routing\Annotation\Route;
1110

@@ -14,14 +13,14 @@
1413
*
1514
* @author Oliver Klee <[email protected]>
1615
*/
17-
class DefaultController extends AbstractController
16+
class DefaultController
1817
{
1918
/**
2019
* An empty start page route.
2120
*
2221
* @throws InvalidArgumentException
2322
*/
24-
#[Route('/', name: 'empty_start_page', methods: ['GET'])]
23+
#[Route('/api/v2', name: 'empty_start_page', methods: ['GET'])]
2524
public function index(): Response
2625
{
2726
return new Response('This page has been intentionally left empty.');

0 commit comments

Comments
 (0)