Skip to content

Commit a41bac9

Browse files
committed
minor #13178 [Validator] Added the missing PHP format in a code example (javiereguiluz)
This PR was merged into the 3.4 branch. Discussion ---------- [Validator] Added the missing PHP format in a code example A minor change ... but it's something that was missing. Commits ------- 00da788 [Validator] Added the missing PHP format in a code example
2 parents e5e04ff + 00da788 commit a41bac9

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)