$base_field_definitions[$field_name] =
$definition;
} } );
// Automatically set the field name, target entity type and bundle
// for non-configurable fields.
foreach ($base_field_definitions as $field_name =>
$base_field_definition) { if ($base_field_definition instanceof BaseFieldDefinition
) { $base_field_definition->
setName($field_name);
$base_field_definition->
setTargetEntityTypeId($entity_type_id);
$base_field_definition->
setTargetBundle(NULL
);
} } // Invoke alter hook.
$this->moduleHandler->
alter('entity_base_field_info',
$base_field_definitions,
$entity_type);
// Ensure defined entity keys are there and have proper revisionable and
// translatable values.
foreach (array_intersect_key($keys,
array_flip(['id', 'revision', 'uuid', 'bundle'
])) as $key =>
$field_name) { if (!
isset($base_field_definitions[$field_name])) { throw new \
LogicException("The
$field_name field definition does not exist and it is used as
$key entity key."
);
}