You are here

public static function BaseFieldOverride::createFromBaseFieldDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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.

1 call to BaseFieldOverride::createFromBaseFieldDefinition()
BaseFieldDefinition::getConfig in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Gets an object that can be saved in configuration.

File

core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php, line 67
Contains \Drupal\Core\Field\Entity\BaseFieldOverride.

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::entityManager()
    ->getStorage('base_field_override')
    ->create($values);
}