private function Mapper::getEnabledBundles in Feeds Paragraphs 8
Gets the enabled bundles for a paragraph field.
Parameters
FieldDefinitionInterface $target:
Return value
array
1 call to Mapper::getEnabledBundles()
- Mapper::getSubFields in src/
Mapper.php
File
- src/
Mapper.php, line 180
Class
Namespace
Drupal\feeds_para_mapperCode
private function getEnabledBundles($target) {
$settings = $target
->getSettings();
$target_bundles = array();
if (isset($settings['handler_settings']['target_bundles'])) {
$target_bundles = $settings['handler_settings']['target_bundles'];
$target_bundles = array_values($target_bundles);
}
else {
if (isset($settings['handler_settings']['target_bundles_drag_drop'])) {
// get the selected bundles:
$selected_bundles = array_filter($settings['handler_settings']['target_bundles_drag_drop'], function ($item) {
return $item['enabled'];
});
if (count($selected_bundles)) {
$target_bundles = array_keys($selected_bundles);
}
else {
// no selected bundles, return all bundles:
$target_bundles = array_keys($settings['handler_settings']['target_bundles_drag_drop']);
}
}
}
// Remove the $target bundle to prevent looping:
$target_bundle = $target
->get('bundle');
$target_bundles = array_filter($target_bundles, function ($item) use ($target_bundle) {
return $item !== $target_bundle;
});
return $target_bundles;
}