You are here

public static function BaseFieldOverride::createFromBaseFieldDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php \Drupal\Core\Field\Entity\BaseFieldOverride::createFromBaseFieldDefinition()

Creates a base field override object.

Parameters

\Drupal\Core\Field\BaseFieldDefinition $base_field_definition: The base field definition to override.

string $bundle: The bundle to which the override applies.

Return value

\Drupal\Core\Field\Entity\BaseFieldOverride A new base field override object.

3 calls to BaseFieldOverride::createFromBaseFieldDefinition()
BaseFieldDefinition::getConfig in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Gets an object that can be saved in configuration.
BaseFieldOverrideTest::testDefaultValueCallback in core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php
Tests the default value callback.
BaseFieldOverrideTest::testGetClass in core/tests/Drupal/KernelTests/Core/Field/Entity/BaseFieldOverrideTest.php
@covers ::getClass

File

core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php, line 63

Class

BaseFieldOverride
Defines the base field override entity.

Namespace

Drupal\Core\Field\Entity

Code

public static function createFromBaseFieldDefinition(BaseFieldDefinition $base_field_definition, $bundle) {
  $values = $base_field_definition
    ->toArray();
  $values['bundle'] = $bundle;
  $values['baseFieldDefinition'] = $base_field_definition;
  return \Drupal::entityTypeManager()
    ->getStorage('base_field_override')
    ->create($values);
}