public function Drupal8::addFieldSettings in Realistic Dummy Content 3.x
Same name and namespace in other branches
- 8.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::addFieldSettings()
- 7.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::addFieldSettings()
Adds field settings if possible.
Parameters
array $return: An array of fields to modify.
string $field: A field name.
array $field_info: Information about the field.
1 call to Drupal8::addFieldSettings()
- Drupal8::fieldInfoFields in api/
src/ Framework/ Drupal8.php - Get information about fields.
File
- api/
src/ Framework/ Drupal8.php, line 177
Class
- Drupal8
- Drupal 8-specific code.
Namespace
Drupal\realistic_dummy_content_api\FrameworkCode
public function addFieldSettings(array &$return, $field, array $field_info) {
if ($field_info['type'] == 'entity_reference') {
if (isset($field_info['bundles']) && count($field_info['bundles'])) {
$bundle = array_pop($field_info['bundles']);
$config = FieldConfig::loadByName('node', $bundle, $field);
if ($config !== NULL) {
$settings = $config
->getSettings();
if (isset($settings['handler_settings']['target_bundles'])) {
foreach ($settings['handler_settings']['target_bundles'] as $target) {
$return[$field]['settings']['allowed_values'][] = [
'vocabulary' => $target,
];
}
}
}
}
}
}