function rng_add_event_field_config in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 8 rng.field.defaults.inc \rng_add_event_field_config()
- 3.x rng.field.defaults.inc \rng_add_event_field_config()
Return value
\Drupal\Core\Field\FieldConfigInterface
2 calls to rng_add_event_field_config()
- EventTypeFieldMappingForm::createField in src/
Form/ EventTypeFieldMappingForm.php - Form submission function to respond to the create field button.
- RngEventType::postSave in src/
Entity/ RngEventType.php - Acts on a saved entity before the insert or update hook is invoked.
File
- ./
rng.field.defaults.inc, line 171 - Creates field config if they do not exist.
Code
function rng_add_event_field_config($field_name, $entity_type, $bundle = NULL) {
if ($field = FieldConfig::loadByName($entity_type, $bundle, $field_name)) {
return NULL;
}
$definition = rng_event_field_config_definition($field_name);
if (!empty($definition)) {
$field = FieldConfig::create([
'field_name' => $field_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
] + $definition);
$field
->save();
}
return $field;
}