I am rewriting my config fields (Field API fields) into base fields and I am unsure about one thing: settings.
Base fields have the setSettings()
method, which I presume is equivalent of field instance settings. Then, there is getFieldStorageDefinition()->setSettings()
, which I presume is equivalent of storage settings.
When I look at the entity reference item and the user ID field used by the node entity, the user ID field calls setSetting('target_type', 'user')
, which is storage setting and not instance setting. Do I get these two wrong? What is going on?
Node::baseFieldDefinitions()
contains the following code.
$fields['uid'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Authored by')) ->setDescription(t('The username of the content author.')) ->setRevisionable(TRUE) ->setSetting('target_type', 'user')
EntityReferenceItem::defaultStorageSettings()
contains the following code.
return [ 'target_type' => Drupal::moduleHandler()->moduleExists('node') ? 'node' : 'user', ] + parent::defaultStorageSettings();