private function Pbf::getPbfEligibleFields in Permissions by field 8
Return the pbf fields eligible to be synchronized.
Eligible fields we can synchronize are those whose target bundle match the bundle of the current field.
Return value
array The list pbf fields
1 call to Pbf::getPbfEligibleFields()
- Pbf::fieldSettingsForm in src/
Plugin/ Field/ FieldType/ Pbf.php - Returns a form for the field-level settings.
File
- src/
Plugin/ Field/ FieldType/ Pbf.php, line 296
Class
- Pbf
- Plugin implementation of the 'pbf' field type.
Namespace
Drupal\pbf\Plugin\Field\FieldTypeCode
private function getPbfEligibleFields($entity_type_id, $target_bundle) {
$fields = $this->entityFieldManager
->getFieldMapByFieldType('pbf');
if (!isset($fields[$entity_type_id])) {
return [];
}
$return = [];
foreach ($fields[$entity_type_id] as $field_name => $field_data) {
foreach ($field_data['bundles'] as $bundle) {
$instance = $this->entityFieldManager
->getFieldDefinitions($entity_type_id, $bundle)[$field_name];
// Only fields with an unlimited cardinality can be synchronized.
if ($instance instanceof FieldConfigInterface && $instance
->getFieldStorageDefinition()
->getCardinality() == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {
$instance_target_bundle = $this
->getTargetBundles($instance);
if (in_array($target_bundle, $instance_target_bundle)) {
$data['entity_type'] = $instance
->getTargetEntityTypeId();
$data['bundle'] = $instance
->getTargetBundle();
$data['label'] = $instance
->getLabel();
$data['field_name'] = $field_name;
$return[$instance
->id()] = $data;
}
}
}
}
return $return;
}