Added base field to Profile entity, which references the Person.

This commit is contained in:
naomi 2018-04-06 00:40:34 +02:00
parent af3b194aa4
commit 60fefb703e
2 changed files with 27 additions and 4 deletions

View File

@ -1,5 +1,3 @@
crm:~/drupal$
070f7a04-6bdc-4992-bc48-20803c6ef0f4
langcode: en
status: true
id: persons

View File

@ -224,9 +224,34 @@ class Profile extends RevisionableContentEntityBase implements ProfileInterface
'autocomplete_type' => 'tags',
'placeholder' => '',
],
]);
$fields['person'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Person'))
->setDescription(t('The person this profile is of.'))
->setSetting('target_type', 'person')
->setSetting('handler', 'views')
->setSetting('handler_settings', [
'view' => [
'view_name' => 'persons',
'display_name' => 'entity_reference_1',
'arguments' => []
]
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
],
])
->setDisplayOptions('view', [
'label' => 'above',
'weight' => 0,
]);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))