You are here

public function BaseFieldDefinition::getConfig in Drupal 9

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

Gets an object that can be saved in configuration.

Base fields are defined in code. In order to configure field definition properties per bundle use this method to create an override that can be saved in configuration.

Parameters

string $bundle: The bundle to get the configurable field for.

Return value

\Drupal\Core\Field\FieldConfigInterface

Overrides FieldDefinitionInterface::getConfig

See also

\Drupal\Core\Field\Entity\BaseFieldBundleOverride

File

core/lib/Drupal/Core/Field/BaseFieldDefinition.php, line 778

Class

BaseFieldDefinition
A class for defining entity fields.

Namespace

Drupal\Core\Field

Code

public function getConfig($bundle) {
  $override = BaseFieldOverride::loadByName($this
    ->getTargetEntityTypeId(), $bundle, $this
    ->getName());
  if ($override) {
    return $override;
  }
  return BaseFieldOverride::createFromBaseFieldDefinition($this, $bundle);
}