Skip to content
Snippets Groups Projects
Commit b4a6273e authored by catch's avatar catch
Browse files

Issue #3231683 by daffie, longwave: [Symfony 6] A number of methods of the...

Issue #3231683 by daffie, longwave: [Symfony 6] A number of methods of the class Drupal\Core\TypedData\Validation\ExecutionContext are considered internal and Drupal should not override them
parent 84e8b971
No related branches found
No related tags found
32 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!2074Issue #2707689: NodeForm::actions() checks for delete access on new entities,!1896Issue #2940605: Can only intentionally re-render an entity with references 20 times,!1459Issue #3087632: menu_name max length is too long,!1398Issue #3186992 by hinal05, djsagar, kiran.kadam911, hitvika_verma,...,!1283Issue #2922435: "Add new comment" and "@count comments" links are not following accessibility good practices,!1255Issue #3238922: Refactor (if feasible) uses of the jQuery serialize function to use vanillaJS,!1254Issue #3238915: Refactor (if feasible) uses of the jQuery ready function to use VanillaJS,!1213Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1185Issue 318778: Rerolled patch.,!1162Issue #3100350: Unable to save '/' root path alias,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!1018Issue #2793343: Dialog drupalAutoButtons option should be respected on initial load,!1014Issue #3226806: Move filter implementations from filter.module to plugin classes,!957Added throwing of InvalidPluginDefinitionException from getDefinition().,!939Issue #2971209: Allow the MediaLibraryUiBuilder service to use an alternative view display,!878Issue #3221534: throw an exception when IDs passed to loadMultiple() are badly formed,!877Issue #2708101: Default value for link text is not saved,!873Issue #2875228: Site install not using batch API service,!872Draft: Issue #3221319: Race condition when creating menu links and editing content deletes menu links,!866Issue #2845319: The highlighting of the 'Home' menu-link does not respect query strings and fragment identifiers,!844Resolve #3036010 "Updaters",!8293023322 - Contextual Links Style Update,!712Issue #2909128: Autocomplete intermittent on Chrome Android,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!485Sets the autocomplete attribute for username/password input field on login form.,!449Issue #2784233: Allow multiple vocabularies in the taxonomy filter,!30Issue #3182188: Updates composer usage to point at ./vendor/bin/composer
......@@ -8,11 +8,11 @@
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\TypedData\Validation\ExecutionContextFactory;
use Drupal\Core\TypedData\Validation\RecursiveValidator;
use Drupal\Core\Validation\ConstraintManager;
use Drupal\Core\Validation\ConstraintValidatorFactory;
use Drupal\Core\Validation\DrupalTranslator;
use Symfony\Component\Validator\Context\ExecutionContextFactory;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
......
......@@ -17,6 +17,10 @@
*
* We do not use the builder provided by Symfony as it is marked internal.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder instead.
*
* @see https://www.drupal.org/node/3238432
*/
class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface {
......@@ -121,6 +125,7 @@ class ConstraintViolationBuilder implements ConstraintViolationBuilderInterface
*/
public function __construct(ConstraintViolationList $violations, Constraint $constraint, $message, array $parameters, $root, $propertyPath, $invalidValue, TranslatorInterface $translator, $translationDomain = null)
{
@trigger_error(__CLASS__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Violation\ConstraintViolationBuilder instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->violations = $violations;
$this->message = $message;
$this->parameters = $parameters;
......@@ -134,9 +139,16 @@ public function __construct(ConstraintViolationList $violations, Constraint $con
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::atPath()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function atPath($path)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::atPath() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->propertyPath = PropertyPath::append($this->propertyPath, $path);
return $this;
......@@ -144,9 +156,16 @@ public function atPath($path)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setParameter()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setParameter($key, $value)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setParameter() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->parameters[$key] = $value;
return $this;
......@@ -154,9 +173,16 @@ public function setParameter($key, $value)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setParameters()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setParameters(array $parameters)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setParameters() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->parameters = $parameters;
return $this;
......@@ -164,9 +190,16 @@ public function setParameters(array $parameters)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setTranslationDomain()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setTranslationDomain($translationDomain)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setTranslationDomain() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->translationDomain = $translationDomain;
return $this;
......@@ -174,9 +207,16 @@ public function setTranslationDomain($translationDomain)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setInvalidValue()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setInvalidValue($invalidValue)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setInvalidValue() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->invalidValue = $invalidValue;
return $this;
......@@ -184,9 +224,16 @@ public function setInvalidValue($invalidValue)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setPlural()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setPlural($number)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setPlural() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->plural = $number;
return $this;
......@@ -194,9 +241,16 @@ public function setPlural($number)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCode()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setCode($code)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCode() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->code = $code;
return $this;
......@@ -204,9 +258,16 @@ public function setCode($code)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCause()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setCause($cause)
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::setCause() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->cause = $cause;
return $this;
......@@ -214,9 +275,16 @@ public function setCause($cause)
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::addViolation()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function addViolation()
{
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Violation\ConstraintViolationBuilder::addViolation() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
if (null === $this->plural) {
$translatedMessage = $this->translator->trans(
$this->message,
......
......@@ -18,6 +18,11 @@
* We do not use the context provided by Symfony as it is marked internal, so
* this class is pretty much the same, but has some code style changes as well
* as exceptions for methods we don't support.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class
* \Symfony\Component\Validator\Context\ExecutionContext instead.
*
* @see https://www.drupal.org/node/3238432
*/
class ExecutionContext implements ExecutionContextInterface {
......@@ -122,6 +127,7 @@ class ExecutionContext implements ExecutionContextInterface {
* Should not be used in user code.
*/
public function __construct(ValidatorInterface $validator, $root, TranslatorInterface $translator, $translationDomain = NULL) {
@trigger_error(__CLASS__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Context\ExecutionContext instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->validator = $validator;
$this->root = $root;
$this->translator = $translator;
......@@ -131,8 +137,15 @@ public function __construct(ValidatorInterface $validator, $root, TranslatorInte
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::setNode()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setNode($value, $object, MetadataInterface $metadata = NULL, $propertyPath) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::setNode() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->value = $value;
$this->data = $object;
$this->metadata = $metadata;
......@@ -141,22 +154,43 @@ public function setNode($value, $object, MetadataInterface $metadata = NULL, $pr
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::setGroup()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setGroup($group) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::setGroup() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->group = $group;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::setConstraint()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function setConstraint(Constraint $constraint) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::setConstraint() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->constraint = $constraint;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::addViolation()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function addViolation($message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::addViolation() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
// The parameters $invalidValue and following are ignored by the new
// API, as they are not present in the new interface anymore.
// You should use buildViolation() instead.
......@@ -169,148 +203,295 @@ public function addViolation($message, array $parameters = [], $invalidValue = N
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::buildViolation()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function buildViolation($message, array $parameters = []): ConstraintViolationBuilderInterface {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::buildViolation() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return new ConstraintViolationBuilder($this->violations, $this->constraint, $message, $parameters, $this->root, $this->propertyPath, $this->value, $this->translator, $this->translationDomain);
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getViolations()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getViolations() {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getViolations() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->violations;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getValidator()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getValidator() {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getValidator() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->validator;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getRoot()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getRoot() {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getRoot() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->root;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getValue()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getValue() {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getValue() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->value;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getObject()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getObject(): ?object {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getObject() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->data;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getMetadata()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getMetadata(): ?MetadataInterface {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getMetadata() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->metadata;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getGroup()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getGroup(): ?string {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getGroup() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return Constraint::DEFAULT_GROUP;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getClassName()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getClassName(): ?string {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getClassName() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return get_class($this->data);
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getPropertyName()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getPropertyName(): ?string {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getPropertyName() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return $this->data->getName();
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getPropertyPath()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getPropertyPath($sub_path = ''): string {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getPropertyPath() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return PropertyPath::append($this->propertyPath, $sub_path);
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::addViolationAt()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function addViolationAt($subPath, $message, array $parameters = [], $invalidValue = NULL, $plural = NULL, $code = NULL) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::addViolationAt() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
throw new \LogicException('Legacy validator API is unsupported.');
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::validate()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function validate($value, $subPath = '', $groups = NULL, $traverse = FALSE, $deep = FALSE) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::validate() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
throw new \LogicException('Legacy validator API is unsupported.');
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::markConstraintAsValidated()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function markConstraintAsValidated($cache_key, $constraint_hash) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::markConstraintAsValidated() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->validatedConstraints[$cache_key . ':' . $constraint_hash] = TRUE;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::isConstraintValidated()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function isConstraintValidated($cache_key, $constraint_hash) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::isConstraintValidated() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return isset($this->validatedConstraints[$cache_key . ':' . $constraint_hash]);
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::validateValue()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function validateValue($value, $constraints, $subPath = '', $groups = NULL) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::validateValue() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
throw new \LogicException('Legacy validator API is unsupported.');
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::markGroupAsValidated()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function markGroupAsValidated($cache_key, $group_hash) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::markGroupAsValidated() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->validatedObjects[$cache_key][$group_hash] = TRUE;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::isGroupValidated()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function isGroupValidated($cache_key, $group_hash) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::isGroupValidated() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return isset($this->validatedObjects[$cache_key][$group_hash]);
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::markObjectAsInitialized()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function markObjectAsInitialized($cache_key) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::markObjectAsInitialized() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
// Not supported, so nothing todo.
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::isObjectInitialized()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function isObjectInitialized($cache_key) {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::isObjectInitialized() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
// Not supported, so nothing todo.
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContext::getMetadataFactory()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function getMetadataFactory() {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContext::getMetadataFactory() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
throw new \LogicException('Legacy validator API is unsupported.');
}
......
......@@ -11,6 +11,11 @@
* Defines an execution factory for the Typed Data validator.
*
* We do not use the factory provided by Symfony as it is marked internal.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class
* \Symfony\Component\Validator\Context\ExecutionContextFactory instead.
*
* @see https://www.drupal.org/node/3238432
*/
class ExecutionContextFactory implements ExecutionContextFactoryInterface {
......@@ -33,14 +38,22 @@ class ExecutionContextFactory implements ExecutionContextFactoryInterface {
* (optional) The translation domain.
*/
public function __construct(TranslatorInterface $translator, $translationDomain = NULL) {
@trigger_error(__CLASS__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Context\ExecutionContextFactory instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
$this->translator = $translator;
$this->translationDomain = $translationDomain;
}
/**
* {@inheritdoc}
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use
* \Symfony\Component\Validator\Context\ExecutionContextFactory::createContext()
* instead.
*
* @see https://www.drupal.org/node/3238432
*/
public function createContext(ValidatorInterface $validator, $root): ExecutionContextInterface {
@trigger_error(__METHOD__ . ' is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Symfony\Component\Validator\Context\ExecutionContextFactory::createContext() instead. See https://www.drupal.org/node/3238432', E_USER_DEPRECATED);
return new ExecutionContext(
$validator,
$root,
......
......@@ -4,6 +4,7 @@
use Drupal\Component\Render\MarkupInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Contracts\Translation\TranslatorInterface;
/**
* Translates strings using Drupal's translation system.
......@@ -28,6 +29,15 @@ public function trans($id, array $parameters = [], $domain = NULL, $locale = NUL
if ($id instanceof TranslatableMarkup) {
return $id;
}
// Symfony violation messages may separate singular and plural versions
// with "|".
$ids = explode('|', $id);
if (count($ids) > 1) {
$number = $parameters['%count%'] ?? 1;
return \Drupal::translation()->formatPlural($number, $ids[0], $ids[1], $this->processParameters($parameters), $this->getOptions($domain, $locale));
}
return new TranslatableMarkup($id, $this->processParameters($parameters), $this->getOptions($domain, $locale));
}
......
......@@ -9,6 +9,10 @@
* to indicate that the Drupal code is actually independent from the
* Symfony translation component.
*
* @deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the
* interface \Symfony\Contracts\Translation\TranslatorInterface instead.
*
* @see https://www.drupal.org/node/3238432
* @see https://github.com/symfony/symfony/pull/6189
* @see https://github.com/symfony/symfony/issues/15714
*/
......
......@@ -12,11 +12,11 @@
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\TypedData\MapDataDefinition;
use Drupal\Core\TypedData\TypedDataManager;
use Drupal\Core\TypedData\Validation\ExecutionContextFactory;
use Drupal\Core\TypedData\Validation\RecursiveValidator;
use Drupal\Core\Validation\ConstraintManager;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Validator\ConstraintValidatorFactory;
use Symfony\Component\Validator\Context\ExecutionContextFactory;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
......@@ -49,7 +49,7 @@ class RecursiveContextualValidatorTest extends UnitTestCase {
/**
* The execution context factory.
*
* @var \Drupal\Core\TypedData\Validation\ExecutionContextFactory
* @var \Symfony\Component\Validator\Context\ExecutionContextFactory
*/
protected $contextFactory;
......@@ -80,7 +80,7 @@ protected function setUp(): void {
$container->set('typed_data_manager', $this->typedDataManager);
\Drupal::setContainer($container);
$translator = $this->createMock('Drupal\Core\Validation\TranslatorInterface');
$translator = $this->createMock('Symfony\Contracts\Translation\TranslatorInterface');
$translator->expects($this->any())
->method('trans')
->willReturnCallback(function ($id) {
......
<?php
namespace Drupal\Tests\Core\TypedData;
use Drupal\Core\TypedData\Validation\ConstraintViolationBuilder;
use Drupal\Core\TypedData\Validation\ExecutionContext;
use Drupal\Core\TypedData\Validation\ExecutionContextFactory;
use Drupal\Core\Validation\TranslatorInterface;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\Validator\ValidatorInterface;
/**
* Test the deprecation of TypedData classes.
* @group typedData
* @group legacy
*/
class ValidationLegacyTest extends UnitTestCase {
/**
* @covers Drupal\Core\TypedData\Validation\ConstraintViolationBuilder::__construct
*/
public function testConstraintViolationBuilderDeprecated() {
$this->expectDeprecation("Drupal\Core\TypedData\Validation\ConstraintViolationBuilder is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Violation\ConstraintViolationBuilder instead. See https://www.drupal.org/node/3238432");
$constraint_violation_list = $this->prophesize(ConstraintViolationList::class)->reveal();
$constraint = $this->prophesize(Constraint::class)->reveal();
$translator = $this->prophesize(TranslatorInterface::class)->reveal();
$this->assertInstanceOf(ConstraintViolationBuilder::class, new ConstraintViolationBuilder($constraint_violation_list, $constraint, '', [], '', '', '', $translator));
}
/**
* @covers Drupal\Core\TypedData\Validation\ExecutionContext::__construct
*/
public function testExecutionContextDeprecated() {
$this->expectDeprecation("Drupal\Core\TypedData\Validation\ExecutionContext is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Context\ExecutionContext instead. See https://www.drupal.org/node/3238432");
$validator = $this->prophesize(ValidatorInterface::class)->reveal();
$translator = $this->prophesize(TranslatorInterface::class)->reveal();
$this->assertInstanceOf(ExecutionContext::class, new ExecutionContext($validator, '', $translator));
}
/**
* @covers Drupal\Core\TypedData\Validation\ExecutionContextFactory::__construct
*/
public function testExecutionContextFactoryDeprecated() {
$this->expectDeprecation("Drupal\Core\TypedData\Validation\ExecutionContextFactory is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use the class \Symfony\Component\Validator\Context\ExecutionContextFactory instead. See https://www.drupal.org/node/3238432");
$translator = $this->prophesize(TranslatorInterface::class)->reveal();
$this->assertInstanceOf(ExecutionContextFactory::class, new ExecutionContextFactory($translator));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment