Skip to content

Commit 80eceb1

Browse files
Merge branch '6.4' into 7.0
* 6.4: Partially revert "DX: PHP CS Fixer - update excluded paths and apply some minor CS" [AssetMapper] Allowing for files to be written to some non-local location [HttpKernel] Resolve EBADP error on flock with LOCK_SH with NFS [AssetMapper] Fixing bug of bad parsing of imports when an import then export are adjacent add missing basque translations [FrameworkBundle][Validator] Allow implementing validation groups provider outside DTOs [Notifier][Novu] Implement overrides [Validator] Handle `null` case [Workflow] List place or transition listeners in profiler [Intl] Add support for emoji 15.1 Replace Tickets by Issues [Validator] Add missing arabic translations [Validator] Added missing translations for Romanian language for Validator component [Messenger] Fix graceful exit with ids [HttpKernel] Add parameters `kernel.runtime_mode` and `kernel.runtime_mode.*`, all set from env var `APP_RUNTIME_MODE`
2 parents 1768a16 + 7960390 commit 80eceb1

23 files changed

+335
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ CHANGELOG
3333
* Deprecate `ValidatorBuilder::enableAnnotationMapping()`, use `ValidatorBuilder::enableAttributeMapping()` instead
3434
* Deprecate `ValidatorBuilder::disableAnnotationMapping()`, use `ValidatorBuilder::disableAttributeMapping()` instead
3535
* Deprecate `AnnotationLoader`, use `AttributeLoader` instead
36+
* Add `GroupProviderInterface` to implement validation group providers outside the underlying class
3637

3738
6.3
3839
---

Constraints/Cascade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Cascade extends Constraint
2525
public function __construct(array|string $exclude = null, array $options = null)
2626
{
2727
if (\is_array($exclude) && !array_is_list($exclude)) {
28-
$options = array_merge($exclude, $options);
28+
$options = array_merge($exclude, $options ?? []);
2929
} else {
3030
$this->exclude = array_flip((array) $exclude);
3131
}

Constraints/GroupSequenceProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\Validator\Constraints;
1313

14+
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
15+
use Symfony\Component\Validator\Attribute\HasNamedArguments;
16+
1417
/**
1518
* Attribute to define a group sequence provider.
1619
*
@@ -19,4 +22,8 @@
1922
#[\Attribute(\Attribute::TARGET_CLASS)]
2023
class GroupSequenceProvider
2124
{
25+
#[HasNamedArguments]
26+
public function __construct(public ?string $provider = null)
27+
{
28+
}
2229
}

GroupProviderInterface.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Validator;
13+
14+
use Symfony\Component\Validator\Constraints\GroupSequence;
15+
16+
/**
17+
* Defines the interface for a validation group provider.
18+
*
19+
* @author Yonel Ceruto <[email protected]>
20+
*/
21+
interface GroupProviderInterface
22+
{
23+
/**
24+
* Returns which validation groups should be used for a certain state
25+
* of the object.
26+
*
27+
* @return string[]|string[][]|GroupSequence
28+
*/
29+
public function getGroups(object $object): array|GroupSequence;
30+
}

Mapping/ClassMetadata.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ class ClassMetadata extends GenericMetadata implements ClassMetadataInterface
8686
*/
8787
public bool $groupSequenceProvider = false;
8888

89+
/**
90+
* @internal This property is public in order to reduce the size of the
91+
* class' serialized representation. Do not access it. Use
92+
* {@link getGroupProvider()} instead.
93+
*/
94+
public ?string $groupProvider = null;
95+
8996
/**
9097
* The strategy for traversing traversable objects.
9198
*
@@ -123,6 +130,7 @@ public function __sleep(): array
123130
'getters',
124131
'groupSequence',
125132
'groupSequenceProvider',
133+
'groupProvider',
126134
'members',
127135
'name',
128136
'properties',
@@ -317,6 +325,7 @@ public function addGetterMethodConstraints(string $property, string $method, arr
317325
public function mergeConstraints(self $source): void
318326
{
319327
if ($source->isGroupSequenceProvider()) {
328+
$this->setGroupProvider($source->getGroupProvider());
320329
$this->setGroupSequenceProvider(true);
321330
}
322331

@@ -428,7 +437,7 @@ public function setGroupSequenceProvider(bool $active): void
428437
throw new GroupDefinitionException('Defining a group sequence provider is not allowed with a static group sequence.');
429438
}
430439

431-
if (!$this->getReflectionClass()->implementsInterface(GroupSequenceProviderInterface::class)) {
440+
if (null === $this->groupProvider && !$this->getReflectionClass()->implementsInterface(GroupSequenceProviderInterface::class)) {
432441
throw new GroupDefinitionException(sprintf('Class "%s" must implement GroupSequenceProviderInterface.', $this->name));
433442
}
434443

@@ -440,6 +449,16 @@ public function isGroupSequenceProvider(): bool
440449
return $this->groupSequenceProvider;
441450
}
442451

452+
public function setGroupProvider(?string $provider): void
453+
{
454+
$this->groupProvider = $provider;
455+
}
456+
457+
public function getGroupProvider(): ?string
458+
{
459+
return $this->groupProvider;
460+
}
461+
443462
public function getCascadingStrategy(): int
444463
{
445464
return $this->cascadingStrategy;

Mapping/ClassMetadataInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
* @see GroupSequence
3131
* @see GroupSequenceProviderInterface
3232
* @see TraversalStrategy
33+
*
34+
* @method string|null getGroupProvider()
3335
*/
3436
interface ClassMetadataInterface extends MetadataInterface
3537
{

Mapping/Loader/XmlFileLoader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ private function loadClassesFromXml(): void
201201
private function loadClassMetadataFromXml(ClassMetadata $metadata, \SimpleXMLElement $classDescription): void
202202
{
203203
if (\count($classDescription->{'group-sequence-provider'}) > 0) {
204+
$metadata->setGroupProvider($classDescription->{'group-sequence-provider'}[0]->value ?: null);
204205
$metadata->setGroupSequenceProvider(true);
205206
}
206207

Mapping/Loader/YamlFileLoader.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ private function loadClassesFromYaml(): void
145145
private function loadClassMetadataFromYaml(ClassMetadata $metadata, array $classDescription): void
146146
{
147147
if (isset($classDescription['group_sequence_provider'])) {
148+
if (\is_string($classDescription['group_sequence_provider'])) {
149+
$metadata->setGroupProvider($classDescription['group_sequence_provider']);
150+
}
148151
$metadata->setGroupSequenceProvider(
149152
(bool) $classDescription['group_sequence_provider']
150153
);

Mapping/Loader/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
validation constraints.
1515
]]></xsd:documentation>
1616
</xsd:annotation>
17-
17+
1818
<xsd:element name="constraint-mapping" type="constraint-mapping" />
19-
19+
2020
<xsd:complexType name="constraint-mapping">
2121
<xsd:annotation>
2222
<xsd:documentation><![CDATA[
@@ -28,7 +28,7 @@
2828
<xsd:element name="class" type="class" maxOccurs="unbounded" />
2929
</xsd:sequence>
3030
</xsd:complexType>
31-
31+
3232
<xsd:complexType name="namespace">
3333
<xsd:annotation>
3434
<xsd:documentation><![CDATA[
@@ -41,13 +41,13 @@
4141
</xsd:extension>
4242
</xsd:simpleContent>
4343
</xsd:complexType>
44-
44+
4545
<xsd:complexType name="class">
4646
<xsd:annotation>
4747
<xsd:documentation><![CDATA[
4848
Contains constraints for a single class.
49-
50-
Nested elements may be class constraints, property and/or getter
49+
50+
Nested elements may be class constraints, property and/or getter
5151
definitions.
5252
]]></xsd:documentation>
5353
</xsd:annotation>
@@ -72,15 +72,18 @@
7272
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
7373
</xsd:sequence>
7474
</xsd:complexType>
75-
75+
7676
<xsd:complexType name="group-sequence-provider">
7777
<xsd:annotation>
7878
<xsd:documentation><![CDATA[
7979
Defines the name of the group sequence provider for a class.
8080
]]></xsd:documentation>
8181
</xsd:annotation>
82+
<xsd:sequence>
83+
<xsd:element name="value" type="value" minOccurs="0" maxOccurs="unbounded" />
84+
</xsd:sequence>
8285
</xsd:complexType>
83-
86+
8487
<xsd:complexType name="property">
8588
<xsd:annotation>
8689
<xsd:documentation><![CDATA[
@@ -93,7 +96,7 @@
9396
</xsd:sequence>
9497
<xsd:attribute name="name" type="xsd:string" use="required" />
9598
</xsd:complexType>
96-
99+
97100
<xsd:complexType name="getter">
98101
<xsd:annotation>
99102
<xsd:documentation><![CDATA[
@@ -106,14 +109,14 @@
106109
</xsd:sequence>
107110
<xsd:attribute name="property" type="xsd:string" use="required" />
108111
</xsd:complexType>
109-
112+
110113
<xsd:complexType name="constraint" mixed="true">
111114
<xsd:annotation>
112115
<xsd:documentation><![CDATA[
113116
Contains a constraint definition. The name of the constraint should be
114117
given in the "name" option.
115-
116-
May contain a single value, multiple "constraint" elements,
118+
119+
May contain a single value, multiple "constraint" elements,
117120
multiple "value" elements or multiple "option" elements.
118121
]]></xsd:documentation>
119122
</xsd:annotation>
@@ -122,15 +125,15 @@
122125
<xsd:element name="option" type="option" minOccurs="1" maxOccurs="unbounded" />
123126
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
124127
</xsd:choice>
125-
<xsd:attribute name="name" type="xsd:string" use="required" />
128+
<xsd:attribute name="name" type="xsd:string" use="required" />
126129
</xsd:complexType>
127-
130+
128131
<xsd:complexType name="option" mixed="true">
129132
<xsd:annotation>
130133
<xsd:documentation><![CDATA[
131134
Contains a constraint option definition. The name of the option
132135
should be given in the "name" option.
133-
136+
134137
May contain a single value, multiple "value" elements or multiple
135138
"constraint" elements.
136139
]]></xsd:documentation>
@@ -139,14 +142,14 @@
139142
<xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
140143
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
141144
</xsd:choice>
142-
<xsd:attribute name="name" type="xsd:string" use="required" />
145+
<xsd:attribute name="name" type="xsd:string" use="required" />
143146
</xsd:complexType>
144-
147+
145148
<xsd:complexType name="value" mixed="true">
146149
<xsd:annotation>
147150
<xsd:documentation><![CDATA[
148151
A value of an element.
149-
152+
150153
May contain a single value, multiple "value" elements or multiple
151154
"constraint" elements.
152155
]]></xsd:documentation>
@@ -155,6 +158,6 @@
155158
<xsd:element name="constraint" type="constraint" minOccurs="1" maxOccurs="unbounded" />
156159
<xsd:element name="value" type="value" minOccurs="1" maxOccurs="unbounded" />
157160
</xsd:choice>
158-
<xsd:attribute name="key" type="xsd:string" use="optional" />
161+
<xsd:attribute name="key" type="xsd:string" use="optional" />
159162
</xsd:complexType>
160163
</xsd:schema>

Resources/translations/validators.ar.xlf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,30 @@
402402
<source>The value of the netmask should be between {{ min }} and {{ max }}.</source>
403403
<target>يجب أن تكون قيمة netmask بين {{ min }} و {{ max }}.</target>
404404
</trans-unit>
405+
<trans-unit id="104">
406+
<source>The filename is too long. It should have {{ filename_max_length }} character or less.|The filename is too long. It should have {{ filename_max_length }} characters or less.</source>
407+
<target>اسم الملف طويل جدا. يجب أن يحتوي على {{ filename_max_length }} حرف أو أقل.|اسم الملف طويل جدا. يجب أن يحتوي على {{ filename_max_length }} أحرف أو أقل.</target>
408+
</trans-unit>
409+
<trans-unit id="105">
410+
<source>The password strength is too low. Please use a stronger password.</source>
411+
<target>قوة كلمة المرور منخفضة للغاية. يرجى استخدام كلمة مرور أقوى.</target>
412+
</trans-unit>
413+
<trans-unit id="106">
414+
<source>This value contains characters that are not allowed by the current restriction-level.</source>
415+
<target>تحتوي هذه القيمة على أحرف غير مسموح بها بواسطة مستوى التقييد الحالي.</target>
416+
</trans-unit>
417+
<trans-unit id="107">
418+
<source>Using invisible characters is not allowed.</source>
419+
<target>لا يسمح باستخدام أحرف غير مرئية.</target>
420+
</trans-unit>
421+
<trans-unit id="108">
422+
<source>Mixing numbers from different scripts is not allowed.</source>
423+
<target>لا يسمح بخلط الأرقام من نصوص مختلفة.</target>
424+
</trans-unit>
425+
<trans-unit id="109">
426+
<source>Using hidden overlay characters is not allowed.</source>
427+
<target>لا يسمح باستخدام أحرف التراكب المخفية.</target>
428+
</trans-unit>
405429
</body>
406430
</file>
407431
</xliff>

0 commit comments

Comments
 (0)