Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConstraintViolationBuilderInterface.php

interface ConstraintViolationBuilderInterface

Builds {@link \Symfony\Component\Validator\ConstraintViolationInterface} objects.

Use the various methods on this interface to configure the built violation. Finally, call {@link addViolation()} to add the violation to the current execution context.

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • interface \Symfony\Component\Validator\Violation\ConstraintViolationBuilderInterface

Expanded class hierarchy of ConstraintViolationBuilderInterface

All classes that implement ConstraintViolationBuilderInterface

4 files declare their use of ConstraintViolationBuilderInterface
ConstraintViolationBuilder.php in core/lib/Drupal/Core/Validation/ConstraintViolationBuilder.php
ExecutionContext.php in vendor/symfony/validator/Context/ExecutionContext.php
ExecutionContext.php in core/lib/Drupal/Core/Validation/ExecutionContext.php
ExecutionContextInterface.php in vendor/symfony/validator/Context/ExecutionContextInterface.php

File

vendor/symfony/validator/Violation/ConstraintViolationBuilderInterface.php, line 24

Namespace

Symfony\Component\Validator\Violation
View source
interface ConstraintViolationBuilderInterface {
    
    /**
     * Stores the property path at which the violation should be generated.
     *
     * The passed path will be appended to the current property path of the
     * execution context.
     *
     * @param string $path The property path
     *
     * @return $this
     */
    public function atPath(string $path) : static;
    
    /**
     * Sets a parameter to be inserted into the violation message.
     *
     * @param string $key   The name of the parameter
     * @param string $value The value to be inserted in the parameter's place
     *
     * @return $this
     */
    public function setParameter(string $key, string $value) : static;
    
    /**
     * Sets all parameters to be inserted into the violation message.
     *
     * @param array $parameters An array with the parameter names as keys and
     *                          the values to be inserted in their place as
     *                          values
     *
     * @return $this
     */
    public function setParameters(array $parameters) : static;
    
    /**
     * @return $this
     */
    public function disableTranslation() : static;
    
    /**
     * Sets the translation domain which should be used for translating the
     * violation message.
     *
     * @param string $translationDomain The translation domain
     *
     * @return $this
     *
     * @see \Symfony\Contracts\Translation\TranslatorInterface
     */
    public function setTranslationDomain(string $translationDomain) : static;
    
    /**
     * Sets the invalid value that caused this violation.
     *
     * @return $this
     */
    public function setInvalidValue(mixed $invalidValue) : static;
    
    /**
     * Sets the number which determines how the plural form of the violation
     * message is chosen when it is translated.
     *
     * @param int $number The number for determining the plural form
     *
     * @return $this
     *
     * @see \Symfony\Contracts\Translation\TranslatorInterface::trans()
     */
    public function setPlural(int $number) : static;
    
    /**
     * Sets the violation code.
     *
     * @param string|null $code The violation code
     *
     * @return $this
     */
    public function setCode(?string $code) : static;
    
    /**
     * Sets the cause of the violation.
     *
     * @param mixed $cause The cause of the violation
     *
     * @return $this
     */
    public function setCause(mixed $cause) : static;
    
    /**
     * Adds the violation to the current execution context.
     */
    public function addViolation() : void;

}

Members

Title Sort descending Modifiers Object type Summary Overrides
ConstraintViolationBuilderInterface::addViolation public function Adds the violation to the current execution context. 2
ConstraintViolationBuilderInterface::atPath public function Stores the property path at which the violation should be generated. 2
ConstraintViolationBuilderInterface::disableTranslation public function 2
ConstraintViolationBuilderInterface::setCause public function Sets the cause of the violation. 2
ConstraintViolationBuilderInterface::setCode public function Sets the violation code. 2
ConstraintViolationBuilderInterface::setInvalidValue public function Sets the invalid value that caused this violation. 2
ConstraintViolationBuilderInterface::setParameter public function Sets a parameter to be inserted into the violation message. 2
ConstraintViolationBuilderInterface::setParameters public function Sets all parameters to be inserted into the violation message. 2
ConstraintViolationBuilderInterface::setPlural public function Sets the number which determines how the plural form of the violation
message is chosen when it is translated.
2
ConstraintViolationBuilderInterface::setTranslationDomain public function Sets the translation domain which should be used for translating the
violation message.
2

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal