public function Drupal8::addFieldSettings in Realistic Dummy Content 7.2
Same name and namespace in other branches
- 8.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::addFieldSettings()
- 3.x 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
File
- api/
src/ Framework/ Drupal8.php, line 181
Class
- Drupal8
- Drupal 8-specific code.
Namespace
Drupal\realistic_dummy_content_api\FrameworkCode
public function addFieldSettings(&$return, $field, $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) {
$settings = $config
->getSettings();
if (isset($settings['handler_settings']['target_bundles'])) {
foreach ($settings['handler_settings']['target_bundles'] as $target) {
$return[$field]['settings']['allowed_values'][] = array(
'vocabulary' => $target,
);
}
}
}
}
}
}