protected function PbfSynchronize::synchronizeTarget in Permissions by field 8
Launch the synchronization belong the operation done on the entity.
Parameters
string $op: The operation to do.
string $field_id: The field id of the Pbf field on target entity.
\Drupal\field\FieldConfigInterface $field: The Pbf field synchroniezd.
\Drupal\Core\Entity\EntityInterface $entity: The entity on which the operation is performed.
1 call to PbfSynchronize::synchronizeTarget()
- PbfSynchronize::synchronize in src/
PbfSynchronize.php - Synchronize a Pbf field form entity.
File
- src/
PbfSynchronize.php, line 182
Class
- PbfSynchronize
- Class PbfSynchronize.
Namespace
Drupal\pbfCode
protected function synchronizeTarget($op, $field_id, FieldConfigInterface $field, EntityInterface $entity) {
$target_entity_type_id = $field
->getSetting('target_type');
/** @var \Drupal\field\FieldConfigInterface $target_field */
$target_field = $this->entityTypeManager
->getStorage('field_config')
->load($field_id);
// We check yet if both fields has an unlimited cardinality. In case where
// the field's cardinality has been changed after been configured to be
// synchronized.
if (!$this
->hasUnlimitedCardinality($field) || !$this
->hasUnlimitedCardinality($target_field)) {
return;
}
switch ($op) {
case 'insert':
$this
->insert($target_entity_type_id, $target_field, $entity, $field);
break;
case 'delete':
$this
->delete($target_entity_type_id, $target_field, $entity, $field);
break;
case 'update':
$this
->update($target_entity_type_id, $target_field, $entity, $field);
break;
default:
break;
}
}