protected function GeysirModalParagraphAddSelectTypeForm::getAllowedBundles in Geysir 8
Returns a list of allowed Paragraph bundles to add.
Parameters
array $allowed_bundles: An array with Paragraph bundles which are allowed to add.
Return value
array Array with allowed Paragraph bundles.
1 call to GeysirModalParagraphAddSelectTypeForm::getAllowedBundles()
- GeysirModalParagraphAddSelectTypeForm::buildForm in src/
Form/ GeysirModalParagraphAddSelectTypeForm.php - Form constructor.
File
- src/
Form/ GeysirModalParagraphAddSelectTypeForm.php, line 81
Class
- GeysirModalParagraphAddSelectTypeForm
- Functionality to select a paragraph type.
Namespace
Drupal\geysir\FormCode
protected function getAllowedBundles($allowed_bundles) {
$bundles = \Drupal::service('entity_type.bundle.info')
->getBundleInfo('paragraph');
if (is_array($allowed_bundles) && count($allowed_bundles)) {
// Only keep allowed bundles.
$bundles = array_intersect_key(array_replace($allowed_bundles, $bundles), $allowed_bundles);
}
// Enrich bundles with their label.
foreach ($bundles as $bundle => $props) {
$label = empty($props['label']) ? ucfirst($bundle) : $props['label'];
$bundles[$bundle] = $label;
}
return $bundles;
}