You are here

class BooleanData in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/BooleanData.php \Drupal\Core\TypedData\Plugin\DataType\BooleanData
  2. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/BooleanData.php \Drupal\Core\TypedData\Plugin\DataType\BooleanData

The boolean data type.

The plain value of a boolean is a regular PHP boolean. For setting the value any PHP variable that casts to a boolean may be passed.

Plugin annotation


@DataType(
  id = "boolean",
  label = @Translation("Boolean")
)

Hierarchy

  • class \Drupal\Core\TypedData\Plugin\DataType\BooleanData extends \Drupal\Core\TypedData\PrimitiveBase implements \Drupal\Core\TypedData\Type\BooleanInterface

Expanded class hierarchy of BooleanData

3 files declare their use of BooleanData
ConfigEntityAdapterTest.php in core/tests/Drupal/KernelTests/Core/Entity/ConfigEntityAdapterTest.php
PrimitiveDataNormalizerTest.php in core/modules/serialization/tests/src/Unit/Normalizer/PrimitiveDataNormalizerTest.php
PrimitiveTypeConstraintValidatorTest.php in core/tests/Drupal/Tests/Core/Validation/Plugin/Validation/Constraint/PrimitiveTypeConstraintValidatorTest.php
1 string reference to 'BooleanData'
core.data_types.schema.yml in core/config/schema/core.data_types.schema.yml
core/config/schema/core.data_types.schema.yml

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/BooleanData.php, line 19

Namespace

Drupal\Core\TypedData\Plugin\DataType
View source
class BooleanData extends PrimitiveBase implements BooleanInterface {

  /**
   * {@inheritdoc}
   */
  public function getCastedValue() {
    return (bool) $this->value;
  }

}

Members