Skip to content

Commit 5f58708

Browse files
author
roadiz-ci
committed
Merge branch release/v2.6.0
1 parent 8d4dd6c commit 5f58708

20 files changed

Lines changed: 253 additions & 145 deletions

.github/workflows/run-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: ubuntu-latest
2020
strategy:
2121
matrix:
22-
php-version: ['8.2', '8.3']
22+
php-version: ['8.3', '8.4']
2323
steps:
2424
- uses: shivammathur/setup-php@v2
2525
with:

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2024 Ambroise Maupate
3+
Copyright © 2025 Ambroise Maupate
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

composer.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@
1818
}
1919
],
2020
"require": {
21-
"php": ">=8.2",
21+
"php": ">=8.3",
2222
"doctrine/orm": "~2.20.0",
23-
"jms/serializer": "^3.32.3",
24-
"roadiz/nodetype-contracts": "^2.0.0",
25-
"symfony/string": "6.4.*",
23+
"api-platform/doctrine-orm": "^4.1.18",
24+
"api-platform/metadata": "^4.1.18",
25+
"roadiz/nodetype-contracts": "^3.0.0",
26+
"symfony/string": "7.3.*",
2627
"symfony/translation-contracts": "^3.0",
27-
"symfony/http-foundation": "6.4.*",
28-
"symfony/serializer": "6.4.*",
29-
"symfony/validator": "6.4.*"
28+
"symfony/http-foundation": "7.3.*",
29+
"symfony/serializer": "7.3.*",
30+
"symfony/uid": "7.3.*",
31+
"symfony/validator": "7.3.*"
3032
},
3133
"require-dev": {
3234
"doctrine/doctrine-bundle": "^2.8.1",
3335
"php-coveralls/php-coveralls": "^2.4",
3436
"phpstan/phpstan": "^1.5.3",
3537
"phpstan/phpdoc-parser": "<2",
36-
"phpunit/phpunit": "^9.5"
38+
"phpunit/phpunit": "^9.6"
3739
},
3840
"autoload": {
3941
"psr-4": {
@@ -53,8 +55,8 @@
5355
},
5456
"extra": {
5557
"branch-alias": {
56-
"dev-master": "2.5.x-dev",
57-
"dev-develop": "2.6.x-dev"
58+
"dev-master": "2.6.x-dev",
59+
"dev-develop": "2.7.x-dev"
5860
}
5961
}
6062
}

src/Bag/LazyParameterBag.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function __construct()
2323
*
2424
* @return mixed|null
2525
*/
26+
#[\Override]
2627
public function get(string $key, $default = null): mixed
2728
{
2829
if (!$this->ready) {
@@ -32,6 +33,7 @@ public function get(string $key, $default = null): mixed
3233
return parent::get($key, $default);
3334
}
3435

36+
#[\Override]
3537
public function all(?string $key = null): array
3638
{
3739
if (!$this->ready) {
@@ -41,6 +43,7 @@ public function all(?string $key = null): array
4143
return parent::all();
4244
}
4345

46+
#[\Override]
4447
public function has(string $key): bool
4548
{
4649
if (!$this->ready) {
@@ -50,6 +53,7 @@ public function has(string $key): bool
5053
return parent::has($key);
5154
}
5255

56+
#[\Override]
5357
public function keys(): array
5458
{
5559
if (!$this->ready) {
@@ -60,6 +64,7 @@ public function keys(): array
6064
}
6165

6266
#[\ReturnTypeWillChange]
67+
#[\Override]
6368
public function getIterator(): \ArrayIterator
6469
{
6570
if (!$this->ready) {
@@ -70,6 +75,7 @@ public function getIterator(): \ArrayIterator
7075
}
7176

7277
#[\ReturnTypeWillChange]
78+
#[\Override]
7379
public function count(): int
7480
{
7581
if (!$this->ready) {
@@ -83,6 +89,7 @@ public function count(): int
8389
* @param null $default
8490
* @param array $options
8591
*/
92+
#[\Override]
8693
public function filter(string $key, $default = null, int $filter = \FILTER_DEFAULT, $options = []): mixed
8794
{
8895
if (!$this->ready) {

src/Core/AbstractEntities/AbstractDateTimed.php

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
namespace RZ\Roadiz\Core\AbstractEntities;
66

77
use Doctrine\ORM\Mapping as ORM;
8-
use JMS\Serializer\Annotation as Serializer;
9-
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
108

119
/**
1210
* An AbstractEntity with datetime fields to keep track of time with your items.
11+
*
12+
* @deprecated since 2.6, use composition with DateTimedTrait instead.
1313
*/
1414
#[
1515
ORM\MappedSuperclass,
@@ -18,81 +18,7 @@
1818
ORM\Index(columns: ['created_at']),
1919
ORM\Index(columns: ['updated_at']),
2020
]
21-
abstract class AbstractDateTimed extends AbstractEntity
21+
abstract class AbstractDateTimed extends AbstractEntity implements DateTimedInterface
2222
{
23-
#[
24-
ORM\Column(name: 'created_at', type: 'datetime', nullable: true),
25-
Serializer\Groups(['timestamps']),
26-
SymfonySerializer\Groups(['timestamps']),
27-
]
28-
protected ?\DateTime $createdAt = null;
29-
30-
#[
31-
ORM\Column(name: 'updated_at', type: 'datetime', nullable: true),
32-
Serializer\Groups(['timestamps']),
33-
SymfonySerializer\Groups(['timestamps']),
34-
]
35-
protected ?\DateTime $updatedAt = null;
36-
37-
public function getCreatedAt(): ?\DateTime
38-
{
39-
return $this->createdAt;
40-
}
41-
42-
/**
43-
* @return $this
44-
*/
45-
public function setCreatedAt(?\DateTime $createdAt): self
46-
{
47-
$this->createdAt = $createdAt;
48-
49-
return $this;
50-
}
51-
52-
public function getUpdatedAt(): ?\DateTime
53-
{
54-
return $this->updatedAt;
55-
}
56-
57-
/**
58-
* @return $this
59-
*/
60-
public function setUpdatedAt(?\DateTime $updatedAt): self
61-
{
62-
$this->updatedAt = $updatedAt;
63-
64-
return $this;
65-
}
66-
67-
protected function initAbstractDateTimed(): void
68-
{
69-
$this->setUpdatedAt(new \DateTime('now'));
70-
$this->setCreatedAt(new \DateTime('now'));
71-
}
72-
73-
#[ORM\PreUpdate]
74-
public function preUpdate(): void
75-
{
76-
$this->setUpdatedAt(new \DateTime('now'));
77-
}
78-
79-
#[ORM\PrePersist]
80-
public function prePersist(): void
81-
{
82-
$this->setUpdatedAt(new \DateTime('now'));
83-
$this->setCreatedAt(new \DateTime('now'));
84-
}
85-
86-
/**
87-
* Set creation and update date to *now*.
88-
*
89-
* @return $this
90-
*/
91-
public function resetDates(): self
92-
{
93-
$this->setCreatedAt(new \DateTime('now'));
94-
$this->setUpdatedAt(new \DateTime('now'));
95-
96-
return $this;
97-
}
23+
use DateTimedTrait;
9824
}

src/Core/AbstractEntities/AbstractEntity.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,17 @@
55
namespace RZ\Roadiz\Core\AbstractEntities;
66

77
use Doctrine\ORM\Mapping as ORM;
8-
use JMS\Serializer\Annotation as Serializer;
9-
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
108

119
/**
1210
* Base entity implementing PersistableInterface to offer a unique ID.
11+
*
12+
* @deprecated since 2.6, use composition with PersistableInterface and SequentialIdTrait or UuidTrait instead.
1313
*/
1414
#[
1515
ORM\MappedSuperclass,
1616
ORM\Table
1717
]
1818
abstract class AbstractEntity implements PersistableInterface
1919
{
20-
#[
21-
ORM\Id,
22-
ORM\Column(type: 'integer'),
23-
ORM\GeneratedValue,
24-
Serializer\Groups(['id']),
25-
Serializer\Type('integer'),
26-
SymfonySerializer\Groups(['id'])
27-
]
28-
protected int|string|null $id = null;
29-
30-
public function getId(): int|string|null
31-
{
32-
return $this->id;
33-
}
34-
35-
public function setId(int|string|null $id): self
36-
{
37-
$this->id = $id;
38-
39-
return $this;
40-
}
20+
use SequentialIdTrait;
4121
}

src/Core/AbstractEntities/AbstractHuman.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44

55
namespace RZ\Roadiz\Core\AbstractEntities;
66

7+
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
8+
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
9+
use ApiPlatform\Metadata\ApiFilter;
710
use Doctrine\ORM\Mapping as ORM;
8-
use JMS\Serializer\Annotation as Serializer;
9-
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
11+
use Symfony\Component\Serializer\Attribute as Serializer;
1012
use Symfony\Component\Validator\Constraints as Assert;
1113

1214
/**
@@ -19,17 +21,20 @@
1921
ORM\Table,
2022
ORM\HasLifecycleCallbacks
2123
]
22-
abstract class AbstractHuman extends AbstractDateTimed
24+
abstract class AbstractHuman implements DateTimedInterface, PersistableInterface
2325
{
24-
#[
25-
ORM\Column(type: 'string', length: 200, unique: true),
26-
Serializer\Groups(['user_personal', 'human']),
27-
SymfonySerializer\Groups(['user_personal', 'human']),
28-
Assert\NotNull(),
29-
Assert\NotBlank(),
30-
Assert\Length(max: 200),
31-
Assert\Email()
32-
]
26+
use SequentialIdTrait;
27+
use DateTimedTrait;
28+
29+
#[ORM\Column(type: 'string', length: 200, unique: true, nullable: false)]
30+
#[Serializer\Groups(['user_personal', 'human'])]
31+
#[Assert\NotNull]
32+
#[Assert\NotBlank]
33+
#[Assert\Length(max: 200)]
34+
#[Assert\Email]
35+
#[ApiFilter(OrderFilter::class)]
36+
#[ApiFilter(SearchFilter::class)]
37+
// @phpstan-ignore-next-line
3338
protected ?string $email = null;
3439

3540
/**
@@ -38,31 +43,27 @@ abstract class AbstractHuman extends AbstractDateTimed
3843
#[
3944
ORM\Column(name: 'publicName', type: 'string', length: 250, nullable: true),
4045
Serializer\Groups(['user_public', 'human']),
41-
SymfonySerializer\Groups(['user_public', 'human']),
4246
Assert\Length(max: 250)
4347
]
4448
protected ?string $publicName = null;
4549

4650
#[
4751
ORM\Column(name: 'firstName', type: 'string', length: 250, nullable: true),
4852
Serializer\Groups(['user_personal', 'human']),
49-
SymfonySerializer\Groups(['user_personal', 'human']),
5053
Assert\Length(max: 250)
5154
]
5255
protected ?string $firstName = null;
5356

5457
#[
5558
ORM\Column(name: 'lastName', type: 'string', length: 250, nullable: true),
5659
Serializer\Groups(['user_personal', 'human']),
57-
SymfonySerializer\Groups(['user_personal', 'human']),
5860
Assert\Length(max: 250)
5961
]
6062
protected ?string $lastName = null;
6163

6264
#[
6365
ORM\Column(type: 'string', length: 250, nullable: true),
6466
Serializer\Groups(['user_personal', 'human']),
65-
SymfonySerializer\Groups(['user_personal', 'human']),
6667
Assert\Length(max: 250)
6768
]
6869
protected ?string $company = null;

src/Core/AbstractEntities/AbstractPositioned.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,27 @@
44

55
namespace RZ\Roadiz\Core\AbstractEntities;
66

7-
use Doctrine\Common\Comparable;
87
use Doctrine\ORM\Mapping as ORM;
9-
use JMS\Serializer\Annotation as Serializer;
10-
use Symfony\Component\Serializer\Annotation as SymfonySerializer;
8+
use Symfony\Component\Serializer\Attribute as Serializer;
119

1210
/**
1311
* Combined AbstractEntity and PositionedTrait.
12+
*
13+
* @deprecated since 2.6, use composition with PositionedTrait and PositionedInterface instead.
1414
*/
1515
#[
1616
ORM\MappedSuperclass,
1717
ORM\HasLifecycleCallbacks,
1818
ORM\Table,
1919
ORM\Index(columns: ['position'])
2020
]
21-
abstract class AbstractPositioned extends AbstractEntity implements PositionedInterface, Comparable
21+
abstract class AbstractPositioned extends AbstractEntity implements PositionedInterface
2222
{
2323
use PositionedTrait;
2424

2525
#[
2626
ORM\Column(type: 'float'),
2727
Serializer\Groups(['position']),
28-
SymfonySerializer\Groups(['position']),
29-
Serializer\Type('float')
3028
]
3129
protected float $position = 0.0;
3230
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace RZ\Roadiz\Core\AbstractEntities;
6+
7+
interface DateTimedInterface
8+
{
9+
public function getCreatedAt(): ?\DateTime;
10+
11+
/**
12+
* @return $this
13+
*/
14+
public function setCreatedAt(?\DateTime $createdAt): self;
15+
16+
public function getUpdatedAt(): ?\DateTime;
17+
18+
/**
19+
* @return $this
20+
*/
21+
public function setUpdatedAt(?\DateTime $updatedAt): self;
22+
}

0 commit comments

Comments
 (0)