Skip to content

Commit 975b49a

Browse files
author
roadiz-ci
committed
Merge branch hotfix/v2.7.24
1 parent d980ee0 commit 975b49a

23 files changed

Lines changed: 319 additions & 147 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: 13 additions & 11 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.1.1",
26+
"symfony/string": "7.4.*",
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.4.*",
29+
"symfony/serializer": "7.4.*",
30+
"symfony/uid": "7.4.*",
31+
"symfony/validator": "7.4.*"
3032
},
3133
"require-dev": {
3234
"doctrine/doctrine-bundle": "^2.8.1",
3335
"php-coveralls/php-coveralls": "^2.4",
34-
"phpstan/phpstan": "^1.5.3",
36+
"phpstan/phpstan": "^2.1.36",
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.7.x-dev",
59+
"dev-develop": "2.8.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 & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,18 @@
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
#[ORM\MappedSuperclass,
1515
ORM\HasLifecycleCallbacks,
1616
ORM\Table,
1717
ORM\Index(columns: ['created_at']),
1818
ORM\Index(columns: ['updated_at']),]
19-
abstract class AbstractDateTimed extends AbstractEntity
19+
abstract class AbstractDateTimed extends AbstractEntity implements DateTimedInterface
2020
{
21-
#[ORM\Column(name: 'created_at', type: 'datetime', nullable: true),
22-
Serializer\Groups(['timestamps']),
23-
SymfonySerializer\Groups(['timestamps']),]
24-
protected ?\DateTime $createdAt = null;
25-
26-
#[ORM\Column(name: 'updated_at', type: 'datetime', nullable: true),
27-
Serializer\Groups(['timestamps']),
28-
SymfonySerializer\Groups(['timestamps']),]
29-
protected ?\DateTime $updatedAt = null;
30-
31-
public function getCreatedAt(): ?\DateTime
32-
{
33-
return $this->createdAt;
34-
}
35-
36-
/**
37-
* @return $this
38-
*/
39-
public function setCreatedAt(?\DateTime $createdAt): self
40-
{
41-
$this->createdAt = $createdAt;
42-
43-
return $this;
44-
}
45-
46-
public function getUpdatedAt(): ?\DateTime
47-
{
48-
return $this->updatedAt;
49-
}
50-
51-
/**
52-
* @return $this
53-
*/
54-
public function setUpdatedAt(?\DateTime $updatedAt): self
55-
{
56-
$this->updatedAt = $updatedAt;
57-
58-
return $this;
59-
}
60-
61-
protected function initAbstractDateTimed(): void
62-
{
63-
$this->setUpdatedAt(new \DateTime('now'));
64-
$this->setCreatedAt(new \DateTime('now'));
65-
}
66-
67-
#[ORM\PreUpdate]
68-
public function preUpdate(): void
69-
{
70-
$this->setUpdatedAt(new \DateTime('now'));
71-
}
72-
73-
#[ORM\PrePersist]
74-
public function prePersist(): void
75-
{
76-
$this->setUpdatedAt(new \DateTime('now'));
77-
$this->setCreatedAt(new \DateTime('now'));
78-
}
79-
80-
/**
81-
* Set creation and update date to *now*.
82-
*
83-
* @return $this
84-
*/
85-
public function resetDates(): self
86-
{
87-
$this->setCreatedAt(new \DateTime('now'));
88-
$this->setUpdatedAt(new \DateTime('now'));
89-
90-
return $this;
91-
}
21+
use DateTimedTrait;
9222
}

src/Core/AbstractEntities/AbstractEntity.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,15 @@
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
#[ORM\MappedSuperclass,
1515
ORM\Table]
1616
abstract class AbstractEntity implements PersistableInterface
1717
{
18-
#[ORM\Id,
19-
ORM\Column(type: 'integer'),
20-
ORM\GeneratedValue,
21-
Serializer\Groups(['id']),
22-
Serializer\Type('integer'),
23-
SymfonySerializer\Groups(['id'])]
24-
protected int|string|null $id = null;
25-
26-
public function getId(): int|string|null
27-
{
28-
return $this->id;
29-
}
30-
31-
public function setId(int|string|null $id): self
32-
{
33-
$this->id = $id;
34-
35-
return $this;
36-
}
18+
use SequentialIdTrait;
3719
}

src/Core/AbstractEntities/AbstractHuman.php

Lines changed: 17 additions & 14 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
/**
@@ -17,41 +19,42 @@
1719
#[ORM\MappedSuperclass,
1820
ORM\Table,
1921
ORM\HasLifecycleCallbacks]
20-
abstract class AbstractHuman extends AbstractDateTimed
22+
abstract class AbstractHuman implements DateTimedInterface, PersistableInterface
2123
{
22-
#[ORM\Column(type: 'string', length: 200, unique: true),
23-
Serializer\Groups(['user_personal', 'human']),
24-
SymfonySerializer\Groups(['user_personal', 'human']),
25-
Assert\NotNull(),
26-
Assert\NotBlank(),
27-
Assert\Length(max: 200),
28-
Assert\Email()]
24+
use SequentialIdTrait;
25+
use DateTimedTrait;
26+
27+
#[ORM\Column(type: 'string', length: 200, unique: true, nullable: false)]
28+
#[Serializer\Groups(['user_personal', 'human'])]
29+
#[Assert\NotNull]
30+
#[Assert\NotBlank]
31+
#[Assert\Length(max: 200)]
32+
#[Assert\Email]
33+
#[ApiFilter(OrderFilter::class)]
34+
#[ApiFilter(SearchFilter::class)]
35+
// @phpstan-ignore-next-line
2936
protected ?string $email = null;
3037

3138
/**
3239
* Public name (pseudonyme) that can be displayed to a public audience.
3340
*/
3441
#[ORM\Column(name: 'publicName', type: 'string', length: 250, nullable: true),
3542
Serializer\Groups(['user_public', 'human']),
36-
SymfonySerializer\Groups(['user_public', 'human']),
3743
Assert\Length(max: 250)]
3844
protected ?string $publicName = null;
3945

4046
#[ORM\Column(name: 'firstName', type: 'string', length: 250, nullable: true),
4147
Serializer\Groups(['user_personal', 'human']),
42-
SymfonySerializer\Groups(['user_personal', 'human']),
4348
Assert\Length(max: 250)]
4449
protected ?string $firstName = null;
4550

4651
#[ORM\Column(name: 'lastName', type: 'string', length: 250, nullable: true),
4752
Serializer\Groups(['user_personal', 'human']),
48-
SymfonySerializer\Groups(['user_personal', 'human']),
4953
Assert\Length(max: 250)]
5054
protected ?string $lastName = null;
5155

5256
#[ORM\Column(type: 'string', length: 250, nullable: true),
5357
Serializer\Groups(['user_personal', 'human']),
54-
SymfonySerializer\Groups(['user_personal', 'human']),
5558
Assert\Length(max: 250)]
5659
protected ?string $company = null;
5760

src/Core/AbstractEntities/AbstractPositioned.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
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
#[ORM\MappedSuperclass,
1616
ORM\HasLifecycleCallbacks,
1717
ORM\Table,
1818
ORM\Index(columns: ['position'])]
19-
abstract class AbstractPositioned extends AbstractEntity implements PositionedInterface, Comparable
19+
abstract class AbstractPositioned extends AbstractEntity implements PositionedInterface
2020
{
2121
use PositionedTrait;
2222

2323
#[ORM\Column(type: 'float'),
24-
Serializer\Groups(['position']),
25-
SymfonySerializer\Groups(['position']),
26-
Serializer\Type('float')]
24+
Serializer\Groups(['position']),]
2725
protected float $position = 0.0;
2826
}
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): static;
15+
16+
public function getUpdatedAt(): ?\DateTime;
17+
18+
/**
19+
* @return $this
20+
*/
21+
public function setUpdatedAt(?\DateTime $updatedAt): static;
22+
}

0 commit comments

Comments
 (0)