You are here

class LegacyConstraintViolationBuilder in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Violation/LegacyConstraintViolationBuilder.php \Symfony\Component\Validator\Violation\LegacyConstraintViolationBuilder

Backwards-compatible implementation of {@link ConstraintViolationBuilderInterface}.

@author Bernhard Schussek <bschussek@gmail.com>

@internal You should not instantiate or use this class. Code against {@link ConstraintViolationBuilderInterface} instead.

Hierarchy

Expanded class hierarchy of LegacyConstraintViolationBuilder

Deprecated

since version 2.5.5, to be removed in 3.0.

1 file declares its use of LegacyConstraintViolationBuilder
ConstraintValidator.php in vendor/symfony/validator/ConstraintValidator.php

File

vendor/symfony/validator/Violation/LegacyConstraintViolationBuilder.php, line 28

Namespace

Symfony\Component\Validator\Violation
View source
class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInterface {

  /**
   * @var ExecutionContextInterface
   */
  private $context;

  /**
   * @var string
   */
  private $message;

  /**
   * @var array
   */
  private $parameters;

  /**
   * @var mixed
   */
  private $invalidValue;

  /**
   * @var string
   */
  private $propertyPath;

  /**
   * @var int|null
   */
  private $plural;

  /**
   * @var mixed
   */
  private $code;
  public function __construct(ExecutionContextInterface $context, $message, array $parameters) {
    $this->context = $context;
    $this->message = $message;
    $this->parameters = $parameters;
    $this->invalidValue = $context
      ->getValue();
  }

  /**
   * {@inheritdoc}
   */
  public function atPath($path) {
    $this->propertyPath = $path;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setParameter($key, $value) {
    $this->parameters[$key] = $value;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setParameters(array $parameters) {
    $this->parameters = $parameters;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setTranslationDomain($translationDomain) {

    // can't be set in the old API
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setInvalidValue($invalidValue) {
    $this->invalidValue = $invalidValue;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setPlural($number) {
    $this->plural = $number;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setCode($code) {
    $this->code = $code;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setCause($cause) {

    // do nothing - we can't save the cause through the old API
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function addViolation() {
    if ($this->propertyPath) {
      $this->context
        ->addViolationAt($this->propertyPath, $this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code);
      return;
    }
    $this->context
      ->addViolation($this->message, $this->parameters, $this->invalidValue, $this->plural, $this->code);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LegacyConstraintViolationBuilder::$code private property
LegacyConstraintViolationBuilder::$context private property
LegacyConstraintViolationBuilder::$invalidValue private property
LegacyConstraintViolationBuilder::$message private property
LegacyConstraintViolationBuilder::$parameters private property
LegacyConstraintViolationBuilder::$plural private property
LegacyConstraintViolationBuilder::$propertyPath private property
LegacyConstraintViolationBuilder::addViolation public function Adds the violation to the current execution context. Overrides ConstraintViolationBuilderInterface::addViolation
LegacyConstraintViolationBuilder::atPath public function Stores the property path at which the violation should be generated. Overrides ConstraintViolationBuilderInterface::atPath
LegacyConstraintViolationBuilder::setCause public function Sets the cause of the violation. Overrides ConstraintViolationBuilderInterface::setCause
LegacyConstraintViolationBuilder::setCode public function Sets the violation code. Overrides ConstraintViolationBuilderInterface::setCode
LegacyConstraintViolationBuilder::setInvalidValue public function Sets the invalid value that caused this violation. Overrides ConstraintViolationBuilderInterface::setInvalidValue
LegacyConstraintViolationBuilder::setParameter public function Sets a parameter to be inserted into the violation message. Overrides ConstraintViolationBuilderInterface::setParameter
LegacyConstraintViolationBuilder::setParameters public function Sets all parameters to be inserted into the violation message. Overrides ConstraintViolationBuilderInterface::setParameters
LegacyConstraintViolationBuilder::setPlural public function Sets the number which determines how the plural form of the violation message is chosen when it is translated. Overrides ConstraintViolationBuilderInterface::setPlural
LegacyConstraintViolationBuilder::setTranslationDomain public function Sets the translation domain which should be used for translating the violation message. Overrides ConstraintViolationBuilderInterface::setTranslationDomain
LegacyConstraintViolationBuilder::__construct public function