private function MessageEntityDelete::createEntityReferenceField in Message 8
Create a multiple entity reference field.
Parameters
bool $multiple: Determine of the field should be multiple.
string $name: The name of the field.
string $target_type: The target type. Default to node.
1 call to MessageEntityDelete::createEntityReferenceField()
- MessageEntityDelete::setUp in tests/
src/ Functional/ MessageEntityDelete.php
File
- tests/
src/ Functional/ MessageEntityDelete.php, line 135
Class
- MessageEntityDelete
- Test the Message delete on entity delete functionality.
Namespace
Drupal\Tests\message\FunctionalCode
private function createEntityReferenceField($multiple, $name, $target_type = 'node') {
// Create a term reference field.
FieldStorageConfig::create([
'field_name' => $name,
'entity_type' => 'message',
'translatable' => FALSE,
'entity_types' => [],
'settings' => [
'target_type' => $target_type,
],
'type' => 'entity_reference',
'cardinality' => $multiple ? FieldStorageConfig::CARDINALITY_UNLIMITED : 1,
])
->save();
FieldConfig::create([
'label' => 'Entity reference field',
'field_name' => $name,
'entity_type' => 'message',
'bundle' => 'dummy_message',
'settings' => [
'handler' => 'default',
'handler_settings' => [
'target_bundles' => [
$target_type,
],
'auto_create' => TRUE,
],
],
])
->save();
}