protected function ParagraphCloneForm::getPotentialCloneDestinations in Paragraphs Edit 8.2
1 call to ParagraphCloneForm::getPotentialCloneDestinations()
- ParagraphCloneForm::form in src/
Form/ ParagraphCloneForm.php - Gets the actual form array to be built.
File
- src/
Form/ ParagraphCloneForm.php, line 139
Class
- ParagraphCloneForm
- ParagraphCloneForm class.
Namespace
Drupal\paragraphs_edit\FormCode
protected function getPotentialCloneDestinations($paragraph_type) {
$types_with_paragraphs = $this->entityManager
->getFieldMapByFieldType('entity_reference_revisions');
$field_definitions_bundle = [];
$destinations = [];
foreach ($types_with_paragraphs as $entity_type_id => $entity_type) {
$bundles_labels = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
foreach ($entity_type as $field => $info) {
foreach ($info['bundles'] as $bundle) {
if (!isset($field_definitions_bundle[$entity_type_id][$bundle])) {
$field_definitions_bundle[$entity_type_id][$bundle] = $this->entityManager
->getFieldDefinitions($entity_type_id, $bundle);
}
/** @var \Drupal\field\FieldConfigInterface $field_definition */
$field_definition = $field_definitions_bundle[$entity_type_id][$bundle][$field];
// Check if field accepts paragraphs of this bundle.
$target_bundles = $field_definition
->getSetting('handler_settings')['target_bundles'];
if (!empty($target_bundles) && in_array($paragraph_type, $target_bundles)) {
$destinations[$entity_type_id]['bundles'][$bundle] = $bundles_labels[$bundle]['label'];
$destinations[$entity_type_id]['fields'][$bundle][$field] = $field_definition
->getLabel();
}
}
}
}
return $destinations;
}