Commit 95faba85 authored by catch's avatar catch
Browse files

Issue #3555533 by longwave, godotislate: Since symfony/validator 7.4: Passing...

Issue #3555533 by longwave, godotislate: Since symfony/validator 7.4: Passing an array of options to configure the constraints is deprecated, use named arguments instead.

(cherry picked from commit cf5d4462)
parent c7018f4f
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@
%Since symfony/dependency-injection 7.4: Service id "Drupal\\Core\\ExampleClass" looks like a FQCN but no corresponding class or interface exists.%
%Since symfony/dom-crawler 7.4: Disabling HTML5 parsing is deprecated. Symfony 8 will unconditionally use the native HTML5 parser.%
%Since symfony/http-foundation 7.4: Request::get\(\) is deprecated, use properties -.*attributes, query or request directly instead.%
%Since symfony/validator 7.4: Passing an array of options to configure the "Drupal\\Core\\[^"]+" constraint is deprecated, use named arguments instead.%
%Since symfony/validator 7.4: Support for evaluating options in the base Constraint class is deprecated. Initialize properties in the constructor of Drupal\\(Core|ckeditor5|file)\\[^ ]+ instead.%
%Since symfony/validator 7.4: Support for passing the choices as the first argument to Drupal\\Core\\[^ ]+ is deprecated.%
%Since symfony/validator 7.4: Support for passing the choices as the first argument to Symfony\\Component\\Validator\\Constraints\\Choice is deprecated.%
+4 −32
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;
use Symfony\Component\Validator\Constraints\Composite;
use Symfony\Component\Validator\Constraints\Existence;

/**
 * Checks that all the keys of a sequence match the specified constraints.
@@ -19,7 +19,7 @@
  label: new TranslatableMarkup('Valid sequence keys', [], ['context' => 'Validation']),
  type: ['sequence']
)]
class ValidSequenceKeysConstraint extends Composite implements ContainerFactoryPluginInterface {
class ValidSequenceKeysConstraint extends Existence implements ContainerFactoryPluginInterface {

  /**
   * The error message if a sequence key is invalid.
@@ -36,38 +36,10 @@ public static function create(ContainerInterface $container, array $configuratio
    $constraints = $configuration['constraints'];
    $constraint_instances = [];
    foreach ($constraints as $constraint_name => $constraint_options) {
      $constraint_instances[$constraint_name] = $constraint_manager->create($constraint_name, $constraint_options);
      $constraint_instances[] = $constraint_manager->create($constraint_name, $constraint_options);
    }

    return new static(['constraints' => $constraint_instances], [SymfonyConstraint::DEFAULT_GROUP]);
  }

  /**
   * Constraint IDs + options specified that are to be applied to sequence keys.
   *
   * @var \Symfony\Component\Validator\Constraint[]
   */
  public array $constraints;

  /**
   * {@inheritdoc}
   */
  public function getDefaultOption(): ?string {
    return 'constraints';
  }

  /**
   * {@inheritdoc}
   */
  public function getRequiredOptions(): array {
    return ['constraints'];
  }

  /**
   * {@inheritdoc}
   */
  protected function getCompositeOption(): string {
    return 'constraints';
    return new static($constraint_instances, [SymfonyConstraint::DEFAULT_GROUP]);
  }

}