Returns the sorted allowed types for the field.
array A list of arrays keyed by the paragraph type machine name with the following properties.
public function getSortedAllowedTypes() {
$return_bundles = [];
$bundles = $this->entityTypeBundleInfo
->getBundleInfo('paragraph');
if (!empty($this->configuration['target_bundles'])) {
if (isset($this->configuration['negate']) && $this->configuration['negate'] == '1') {
$bundles = array_diff_key($bundles, $this->configuration['target_bundles']);
}
else {
$bundles = array_intersect_key($bundles, $this->configuration['target_bundles']);
}
}
// Support for the paragraphs reference type.
if (!empty($this->configuration['target_bundles_drag_drop'])) {
$drag_drop_settings = $this->configuration['target_bundles_drag_drop'];
$max_weight = count($bundles);
foreach ($drag_drop_settings as $bundle_info) {
if (isset($bundle_info['weight']) && $bundle_info['weight'] && $bundle_info['weight'] > $max_weight) {
$max_weight = $bundle_info['weight'];
}
}
// Default weight for new items.
$weight = $max_weight + 1;
foreach ($bundles as $machine_name => $bundle) {
$return_bundles[$machine_name] = [
'label' => $bundle['label'],
'weight' => isset($drag_drop_settings[$machine_name]['weight']) ? $drag_drop_settings[$machine_name]['weight'] : $weight,
];
$weight++;
}
}
else {
$weight = 0;
foreach ($bundles as $machine_name => $bundle) {
$return_bundles[$machine_name] = [
'label' => $bundle['label'],
'weight' => $weight,
];
$weight++;
}
}
uasort($return_bundles, 'Drupal\\Component\\Utility\\SortArray::sortByWeightElement');
return $return_bundles;
}