FileEncodingConstraint.php

Same filename and directory in other branches
  1. 11.x core/modules/file/src/Plugin/Validation/Constraint/FileEncodingConstraint.php

Namespace

Drupal\file\Plugin\Validation\Constraint

File

core/modules/file/src/Plugin/Validation/Constraint/FileEncodingConstraint.php

View source
<?php

declare (strict_types=1);
namespace Drupal\file\Plugin\Validation\Constraint;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Validation\Attribute\Constraint;
use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint as SymfonyConstraint;

/**
 * Defines an encoding constraint for files.
 */
class FileEncodingConstraint extends SymfonyConstraint {
  
  /**
   * The allowed file encodings.
   *
   * @var array
   */
  public array $encodings;
  public function __construct(mixed $options = NULL, ?array $encodings = NULL, public string $message = "The file is encoded with %detected. It must be encoded with %encoding", ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct($options, $groups, $payload);
    $this->encodings = $encodings ?? $this->encodings;
  }

}

Classes

Title Deprecated Summary
FileEncodingConstraint Defines an encoding constraint for files.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.