4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Validator;
15 * A container for validation metadata.
17 * The container contains constraints that may belong to different validation
18 * groups. Constraints for a specific group can be fetched by calling
19 * {@link findConstraints}.
21 * Implement this interface to add validation metadata to your own metadata
22 * layer. Each metadata may have named properties. Each property can be
23 * represented by one or more {@link PropertyMetadataInterface} instances that
24 * are returned by {@link getPropertyMetadata}. Since
25 * <tt>PropertyMetadataInterface</tt> inherits from <tt>MetadataInterface</tt>,
26 * each property may be divided into further properties.
28 * The {@link accept} method of each metadata implements the Visitor pattern.
29 * The method should forward the call to the visitor's
30 * {@link ValidationVisitorInterface::visit} method and additionally call
31 * <tt>accept()</tt> on all structurally related metadata instances.
33 * For example, to store constraints for PHP classes and their properties,
34 * create a class <tt>ClassMetadata</tt> (implementing <tt>MetadataInterface</tt>)
35 * and a class <tt>PropertyMetadata</tt> (implementing <tt>PropertyMetadataInterface</tt>).
36 * <tt>ClassMetadata::getPropertyMetadata($property)</tt> returns all
37 * <tt>PropertyMetadata</tt> instances for a property of that class. Its
38 * <tt>accept()</tt>-method simply forwards to <tt>ValidationVisitorInterface::visit()</tt>
39 * and calls <tt>accept()</tt> on all contained <tt>PropertyMetadata</tt>
40 * instances, which themselves call <tt>ValidationVisitorInterface::visit()</tt>
43 * @author Bernhard Schussek <bschussek@gmail.com>
45 * @deprecated since version 2.5, to be removed in 3.0.
46 * Use {@link Mapping\MetadataInterface} instead.
48 interface MetadataInterface
51 * Implementation of the Visitor design pattern.
53 * Calls {@link ValidationVisitorInterface::visit} and then forwards the
54 * <tt>accept()</tt>-call to all property metadata instances.
56 * @param ValidationVisitorInterface $visitor The visitor implementing the validation logic
57 * @param mixed $value The value to validate
58 * @param string|string[] $group The validation group to validate in
59 * @param string $propertyPath The current property path in the validation graph
61 * @deprecated since version 2.5, to be removed in 3.0.
63 public function accept(ValidationVisitorInterface $visitor, $value, $group, $propertyPath);
66 * Returns all constraints for a given validation group.
68 * @param string $group The validation group
70 * @return Constraint[] A list of constraint instances
72 public function findConstraints($group);