Commit 9ced9d5a authored by catch's avatar catch

Issue #2047997 by jlindsey15, swentel: Get rid of field_behaviors_widget().

parent 714f9e3e
......@@ -44,29 +44,6 @@ function field_info_cache_clear() {
Field::fieldInfo()->flush();
}
/**
* Determines the behavior of a widget with respect to an operation.
*
* @param string $op
* The name of the operation. Currently supported: 'default_value',
* 'multiple_values'.
* @param array $instance
* The field instance array.
*
* @return int
* One of these values:
* - FIELD_BEHAVIOR_NONE: Do nothing for this operation.
* - FIELD_BEHAVIOR_CUSTOM: Use the widget's callback function.
* - FIELD_BEHAVIOR_DEFAULT: Use field.module default behavior.
*/
function field_behaviors_widget($op, $instance) {
$info = array();
if ($component = entity_get_form_display($instance['entity_type'], $instance['bundle'], 'default')->getComponent($instance['field_name'])) {
$info = \Drupal::service('plugin.manager.field.widget')->getDefinition($component['type']);
}
return isset($info[$op]) ? $info[$op] : FIELD_BEHAVIOR_DEFAULT;
}
/**
* Returns all field definitions.
*
......
......@@ -588,11 +588,6 @@ public function prepareInstance($instance, $field_type) {
// Make sure all expected instance settings are present.
$instance['settings'] += $this->fieldTypeManager->getDefaultInstanceSettings($field_type);
// Set a default value for the instance.
if (field_behaviors_widget('default value', $instance) == FIELD_BEHAVIOR_DEFAULT && !isset($instance['default_value'])) {
$instance['default_value'] = NULL;
}
return $instance;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment