Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / validator / Context / ExecutionContextInterface.php
index d38d33747a752ac4e36df15cdd653888137bd3fd..1b1452582dff454e0177cfd737a3fae7c9a6c7cc 100644 (file)
 namespace Symfony\Component\Validator\Context;
 
 use Symfony\Component\Validator\Constraint;
-use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface;
+use Symfony\Component\Validator\Mapping;
 use Symfony\Component\Validator\Mapping\MetadataInterface;
 use Symfony\Component\Validator\Validator\ValidatorInterface;
 use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
+use Symfony\Component\Validator\ConstraintViolationListInterface;
 
 /**
  * The context of a validation run.
@@ -58,8 +59,16 @@ use Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface;
  *
  * @author Bernhard Schussek <bschussek@gmail.com>
  */
-interface ExecutionContextInterface extends LegacyExecutionContextInterface
+interface ExecutionContextInterface
 {
+    /**
+     * Adds a violation at the current node of the validation graph.
+     *
+     * @param string $message The error message
+     * @param array  $params  The parameters substituted in the error message
+     */
+    public function addViolation($message, array $params = array());
+
     /**
      * Returns a builder for adding a violation with extended information.
      *
@@ -222,4 +231,114 @@ interface ExecutionContextInterface extends LegacyExecutionContextInterface
      * @see ObjectInitializerInterface
      */
     public function isObjectInitialized($cacheKey);
+
+    /**
+     * Returns the violations generated by the validator so far.
+     *
+     * @return ConstraintViolationListInterface The constraint violation list
+     */
+    public function getViolations();
+
+    /**
+     * Returns the value at which validation was started in the object graph.
+     *
+     * The validator, when given an object, traverses the properties and
+     * related objects and their properties. The root of the validation is the
+     * object from which the traversal started.
+     *
+     * The current value is returned by {@link getValue}.
+     *
+     * @return mixed The root value of the validation
+     */
+    public function getRoot();
+
+    /**
+     * Returns the value that the validator is currently validating.
+     *
+     * If you want to retrieve the object that was originally passed to the
+     * validator, use {@link getRoot}.
+     *
+     * @return mixed The currently validated value
+     */
+    public function getValue();
+
+    /**
+     * Returns the metadata for the currently validated value.
+     *
+     * With the core implementation, this method returns a
+     * {@link Mapping\ClassMetadataInterface} instance if the current value is an object,
+     * a {@link Mapping\PropertyMetadata} instance if the current value is
+     * the value of a property and a {@link Mapping\GetterMetadata} instance if
+     * the validated value is the result of a getter method.
+     *
+     * If the validated value is neither of these, for example if the validator
+     * has been called with a plain value and constraint, this method returns
+     * null.
+     *
+     * @return MetadataInterface|null The metadata of the currently validated
+     *                                value.
+     */
+    public function getMetadata();
+
+    /**
+     * Returns the validation group that is currently being validated.
+     *
+     * @return string The current validation group
+     */
+    public function getGroup();
+
+    /**
+     * Returns the class name of the current node.
+     *
+     * If the metadata of the current node does not implement
+     * {@link Mapping\ClassMetadataInterface} or if no metadata is available for the
+     * current node, this method returns null.
+     *
+     * @return string|null The class name or null, if no class name could be found
+     */
+    public function getClassName();
+
+    /**
+     * Returns the property name of the current node.
+     *
+     * If the metadata of the current node does not implement
+     * {@link PropertyMetadataInterface} or if no metadata is available for the
+     * current node, this method returns null.
+     *
+     * @return string|null The property name or null, if no property name could be found
+     */
+    public function getPropertyName();
+
+    /**
+     * Returns the property path to the value that the validator is currently
+     * validating.
+     *
+     * For example, take the following object graph:
+     *
+     * <pre>
+     * (Person)---($address: Address)---($street: string)
+     * </pre>
+     *
+     * When the <tt>Person</tt> instance is passed to the validator, the
+     * property path is initially empty. When the <tt>$address</tt> property
+     * of that person is validated, the property path is "address". When
+     * the <tt>$street</tt> property of the related <tt>Address</tt> instance
+     * is validated, the property path is "address.street".
+     *
+     * Properties of objects are prefixed with a dot in the property path.
+     * Indices of arrays or objects implementing the {@link \ArrayAccess}
+     * interface are enclosed in brackets. For example, if the property in
+     * the previous example is <tt>$addresses</tt> and contains an array
+     * of <tt>Address</tt> instance, the property path generated for the
+     * <tt>$street</tt> property of one of these addresses is for example
+     * "addresses[0].street".
+     *
+     * @param string $subPath Optional. The suffix appended to the current
+     *                        property path.
+     *
+     * @return string The current property path. The result may be an empty
+     *                string if the validator is currently validating the
+     *                root value of the validation graph.
+     */
+    public function getPropertyPath($subPath = '');
 }