8000 [Validator] Added the missing PHP format in a code example · symfony/symfony-docs@00da788 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00da788

Browse files
committed
[Validator] Added the missing PHP format in a code example
1 parent e5e04ff commit 00da788

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
@@ -234,3 +234,19 @@ not to the property:
234234
<class name="AppBundle\Entity\AcmeEntity">
235235
<constraint name="AppBundle\Validator\Constraints\ProtocolClass"/>
236236
</class>
237+
238+
.. code-block:: php
239+
240+
// src/AppBundle/Entity/AcmeEntity.php
241+
use AppBundle\Validator\Constraints\ProtocolClass;
242+
use Symfony\Component\Validator\Mapping\ClassMetadata;
243+
244+
class AcmeEntity
245+
{
246+
// ...
247+
248+
public static function loadValidatorMetadata(ClassMetadata $metadata)
249+
{
250+
$metadata->addConstraint(new ProtocolClass());
251+
}
252+
}

0 commit comments

Comments
 (0)
0