Enum.php

Same filename in this branch
  1. main core/lib/Drupal/Component/Annotation/Doctrine/Annotation/Enum.php
Same filename and directory in other branches
  1. 11.x core/lib/Drupal/Component/Annotation/Doctrine/Annotation/Enum.php
  2. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Enum.php

Namespace

Drupal\Core\TypedData\Plugin\DataType

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/Enum.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Core\TypedData\Plugin\DataType;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\Attribute\DataType;
use Drupal\Core\TypedData\PrimitiveBase;

/**
 * The "enum" data type.
 *
 * @ingroup typed_data
 */
class Enum extends PrimitiveBase {
  
  /**
   * {@inheritdoc}
   */
  public function getConstraints() : array {
    $constraints = parent::getConstraints();
    $constraints[] = $this->getTypedDataManager()
      ->getValidationConstraintManager()
      ->create('Enum', []);
    return $constraints;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getCastedValue() {
    return $this->getValue();
  }

}

Classes

Title Deprecated Summary
Enum The "enum" data type.

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