function BaseFieldOverride::createFromBaseFieldDefinition

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php \Drupal\Core\Field\Entity\BaseFieldOverride::createFromBaseFieldDefinition()
  2. 10 core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php \Drupal\Core\Field\Entity\BaseFieldOverride::createFromBaseFieldDefinition()
  3. 11.x 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);
}

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