Skip to content

Commit 07c3fdf

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Remove AppBundle form path and namespace. refs #13178 [Validator] Added the missing PHP format in a code example
2 parents 77d6a59 + e5b94a5 commit 07c3fdf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

validation/custom_constraint.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,19 @@ not to the property:
240240
<class name="App\Entity\AcmeEntity">
241241
<constraint name="App\Validator\Constraints\ProtocolClass"/>
242242
</class>
243+
244+
.. code-block:: php
245+
246+
// src/Entity/AcmeEntity.php
247+
use App\Validator\Constraints\ProtocolClass;
248+
use Symfony\Component\Validator\Mapping\ClassMetadata;
249+
250+
class AcmeEntity
251+
{
252+
// ...
253+
254+
public static function loadValidatorMetadata(ClassMetadata $metadata)
255+
{
256+
$metadata->addConstraint(new ProtocolClass());
257+
}
258+
}

0 commit comments

Comments
 (0)