Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
226
vendor/symfony/validator/Violation/ConstraintViolationBuilder.php
vendored
Normal file
226
vendor/symfony/validator/Violation/ConstraintViolationBuilder.php
vendored
Normal file
|
@ -0,0 +1,226 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Validator\Violation;
|
||||
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintViolation;
|
||||
use Symfony\Component\Validator\ConstraintViolationList;
|
||||
use Symfony\Component\Validator\Util\PropertyPath;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link ConstraintViolationBuilderInterface}.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @internal You should not instantiate or use this class. Code against
|
||||
* {@link ConstraintViolationBuilderInterface} instead.
|
||||
*/
|
||||
class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
|
||||
{
|
||||
/**
|
||||
* @var ConstraintViolationList
|
||||
*/
|
||||
private $violations;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $root;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $invalidValue;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $propertyPath;
|
||||
|
||||
/**
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
private $translator;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $translationDomain;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $plural;
|
||||
|
||||
/**
|
||||
* @var Constraint
|
||||
*/
|
||||
private $constraint;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
private $cause;
|
||||
|
||||
public function __construct(ConstraintViolationList $violations, Constraint $constraint, $message, array $parameters, $root, $propertyPath, $invalidValue, TranslatorInterface $translator, $translationDomain = null)
|
||||
{
|
||||
$this->violations = $violations;
|
||||
$this->message = $message;
|
||||
$this->parameters = $parameters;
|
||||
$this->root = $root;
|
||||
$this->propertyPath = $propertyPath;
|
||||
$this->invalidValue = $invalidValue;
|
||||
$this->translator = $translator;
|
||||
$this->translationDomain = $translationDomain;
|
||||
$this->constraint = $constraint;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function atPath($path)
|
||||
{
|
||||
$this->propertyPath = PropertyPath::append($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)
|
||||
{
|
||||
$this->translationDomain = $translationDomain;
|
||||
|
||||
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)
|
||||
{
|
||||
$this->cause = $cause;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function addViolation()
|
||||
{
|
||||
if (null === $this->plural) {
|
||||
$translatedMessage = $this->translator->trans(
|
||||
$this->message,
|
||||
$this->parameters,
|
||||
$this->translationDomain
|
||||
);
|
||||
} else {
|
||||
try {
|
||||
$translatedMessage = $this->translator->transChoice(
|
||||
$this->message,
|
||||
$this->plural,
|
||||
$this->parameters,
|
||||
$this->translationDomain#
|
||||
);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$translatedMessage = $this->translator->trans(
|
||||
$this->message,
|
||||
$this->parameters,
|
||||
$this->translationDomain
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->violations->add(new ConstraintViolation(
|
||||
$translatedMessage,
|
||||
$this->message,
|
||||
$this->parameters,
|
||||
$this->root,
|
||||
$this->propertyPath,
|
||||
$this->invalidValue,
|
||||
$this->plural,
|
||||
$this->code,
|
||||
$this->constraint,
|
||||
$this->cause
|
||||
));
|
||||
}
|
||||
}
|
116
vendor/symfony/validator/Violation/ConstraintViolationBuilderInterface.php
vendored
Normal file
116
vendor/symfony/validator/Violation/ConstraintViolationBuilderInterface.php
vendored
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Validator\Violation;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 2.5
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
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 ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function atPath($path);
|
||||
|
||||
/**
|
||||
* 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 ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function setParameter($key, $value);
|
||||
|
||||
/**
|
||||
* 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 ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function setParameters(array $parameters);
|
||||
|
||||
/**
|
||||
* Sets the translation domain which should be used for translating the
|
||||
* violation message.
|
||||
*
|
||||
* @param string $translationDomain The translation domain
|
||||
*
|
||||
* @return ConstraintViolationBuilderInterface This builder
|
||||
*
|
||||
* @see \Symfony\Component\Translation\TranslatorInterface
|
||||
*/
|
||||
public function setTranslationDomain($translationDomain);
|
||||
|
||||
/**
|
||||
* Sets the invalid value that caused this violation.
|
||||
*
|
||||
* @param mixed $invalidValue The invalid value
|
||||
*
|
||||
* @return ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function setInvalidValue($invalidValue);
|
||||
|
||||
/**
|
||||
* 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 ConstraintViolationBuilderInterface This builder
|
||||
*
|
||||
* @see \Symfony\Component\Translation\TranslatorInterface::transChoice()
|
||||
*/
|
||||
public function setPlural($number);
|
||||
|
||||
/**
|
||||
* Sets the violation code.
|
||||
*
|
||||
* @param int $code The violation code
|
||||
*
|
||||
* @return ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function setCode($code);
|
||||
|
||||
/**
|
||||
* Sets the cause of the violation.
|
||||
*
|
||||
* @param mixed $cause The cause of the violation
|
||||
*
|
||||
* @return ConstraintViolationBuilderInterface This builder
|
||||
*/
|
||||
public function setCause($cause);
|
||||
|
||||
/**
|
||||
* Adds the violation to the current execution context.
|
||||
*/
|
||||
public function addViolation();
|
||||
}
|
166
vendor/symfony/validator/Violation/LegacyConstraintViolationBuilder.php
vendored
Normal file
166
vendor/symfony/validator/Violation/LegacyConstraintViolationBuilder.php
vendored
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Validator\Violation;
|
||||
|
||||
@trigger_error('The '.__NAMESPACE__.'\LegacyConstraintViolationBuilder class is deprecated since version 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
|
||||
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @deprecated since version 2.5.5, to be removed in 3.0.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
Reference in a new issue