public function FieldInfo::prepareInstance

Prepares an instance definition for the current run-time context.

Parameters

$instance: The raw instance structure as read from the database.

$field_type: The field type.

Return value

The field instance array completed for the current runtime context.

2 calls to FieldInfo::prepareInstance()
FieldInfo::getBundleInstances in drupal/core/modules/field/lib/Drupal/field/FieldInfo.php
Retrieves the instances for a bundle.
FieldInfo::getInstances in drupal/core/modules/field/lib/Drupal/field/FieldInfo.php
Retrieves all active, non-deleted instances definitions.

File

drupal/core/modules/field/lib/Drupal/field/FieldInfo.php, line 552
Contains \Drupal\field\FieldInfo.

Class

FieldInfo
Provides field and instance definitions for the current runtime environment.

Namespace

Drupal\field

Code

public function prepareInstance($instance, $field_type) {

  // Make sure all expected instance settings are present.
  $instance['settings'] += field_info_instance_settings($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;
}