Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Week.php

class Week

@author Alexandre Daubois <alex.daubois@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Week extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of Week

2 string references to 'Week'
claro_preprocess_input in core/themes/claro/claro.theme
Implements template_preprocess_HOOK() for input.
olivero_preprocess_input in core/themes/olivero/olivero.theme
Implements hook_preprocess_HOOK().

File

vendor/symfony/validator/Constraints/Week.php, line 21

Namespace

Symfony\Component\Validator\Constraints
View source
final class Week extends Constraint {
    public const INVALID_FORMAT_ERROR = '19012dd1-01c8-4ce8-959f-72ad22684f5f';
    public const INVALID_WEEK_NUMBER_ERROR = 'd67ebfc9-45fe-4e4c-a038-5eaa56895ea3';
    public const TOO_LOW_ERROR = '9b506423-77a3-4749-aa34-c822a08be978';
    public const TOO_HIGH_ERROR = '85156377-d1e6-42cd-8f6e-dc43c2ecb72b';
    protected const ERROR_NAMES = [
        self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
        self::INVALID_WEEK_NUMBER_ERROR => 'INVALID_WEEK_NUMBER_ERROR',
        self::TOO_LOW_ERROR => 'TOO_LOW_ERROR',
        self::TOO_HIGH_ERROR => 'TOO_HIGH_ERROR',
    ];
    
    /**
     * @param non-empty-string|null $min
     * @param non-empty-string|null $max
     */
    public function __construct(?string $min = null, ?string $max = null, string $invalidFormatMessage = 'This value does not represent a valid week in the ISO 8601 format.', string $invalidWeekNumberMessage = 'This value is not a valid week.', string $tooLowMessage = 'This value should not be before week "{{ min }}".', string $tooHighMessage = 'This value should not be after week "{{ max }}".', ?array $groups = null, mixed $payload = null) {
        parent::__construct(null, $groups, $payload);
        if (null !== $min && !preg_match('/^\\d{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$/', $min)) {
            throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires the min week to be in the ISO 8601 format if set.', __CLASS__));
        }
        if (null !== $max && !preg_match('/^\\d{4}-W(0[1-9]|[1-4][0-9]|5[0-3])$/', $max)) {
            throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires the max week to be in the ISO 8601 format if set.', __CLASS__));
        }
        if (null !== $min && null !== $max) {
            [
                $minYear,
                $minWeekNumber,
            ] = explode('-W', $min, 2);
            [
                $maxYear,
                $maxWeekNumber,
            ] = explode('-W', $max, 2);
            if ($minYear > $maxYear || $minYear === $maxYear && $minWeekNumber > $maxWeekNumber) {
                throw new ConstraintDefinitionException(\sprintf('The "%s" constraint requires the min week to be less than or equal to the max week.', __CLASS__));
            }
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
Constraint::$groups public property The groups that the constraint belongs to.
Constraint::$payload public property Domain-specific data attached to a constraint.
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group. 2
Constraint::CLASS_CONSTRAINT public constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP public constant The name of the group given to all constraints with no explicit group.
Constraint::getDefaultOption public function Returns the name of the default option. 28
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::getRequiredOptions public function Returns the name of the required options. 22
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or
both.
8
Constraint::normalizeOptions protected function
Constraint::PROPERTY_CONSTRAINT public constant Marks a constraint that can be put onto properties.
Constraint::validatedBy public function Returns the name of the class that validates this constraint. 9
Constraint::__get public function Returns the value of a lazily initialized option. 2
Constraint::__isset public function 1
Constraint::__set public function Sets the value of a lazily initialized option. 1
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.
Week::ERROR_NAMES protected constant Maps error codes to the names of their constants. Overrides Constraint::ERROR_NAMES
Week::INVALID_FORMAT_ERROR public constant
Week::INVALID_WEEK_NUMBER_ERROR public constant
Week::TOO_HIGH_ERROR public constant
Week::TOO_LOW_ERROR public constant
Week::__construct public function Overrides Constraint::__construct
RSS feed
Powered by Drupal