function pbf_field_config_insert in Permissions by field 8
Implements hook_ENTITY_TYPE_insert().
File
- ./
pbf.module, line 272 - Contains pbf.module.
Code
function pbf_field_config_insert(FieldConfigInterface $entity) {
if ($entity
->getType() == 'pbf' && $entity
->getSetting('synchronized_with')) {
$entityTypeManager = \Drupal::entityTypeManager()
->getStorage('field_config');
/** @var \Drupal\field\FieldConfigInterface $field_to_synchronize */
$field_to_synchronize = $entityTypeManager
->load($entity
->getSetting('synchronized_with'));
if ($field_to_synchronize) {
$field_to_synchronize
->set('synchronized_by', $entity
->id())
->set('synchronized_from_target', $entity
->getSetting('synchronized_from_target'))
->save();
}
}
}