diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index bbd0d45..36356e0 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -25,89 +25,6 @@ */ /** - * Creates a field. - * - * This function does not bind the field to any bundle; use - * field_create_instance() for that. - * - * @param array $field - * A field definition. The field_name and type properties are required. - * Other properties, if omitted, will be given the following default values: - * - cardinality: 1 - * - locked: FALSE - * - indexes: the field-type indexes, specified by the field type's - * hook_field_schema(). The indexes specified in $field are added - * to those default indexes. It is possible to override the - * definition of a field-type index by providing an index with the - * same name, or to remove it by redefining it as an empty array - * of columns. Overriding field-type indexes should be done - * carefully, for it might seriously affect the site's performance. - * - settings: each omitted setting is given the default value defined in - * hook_field_info(). - * - storage: - * - type: the storage backend specified in the - * 'field.settings.default_storage' configuration. - * - settings: each omitted setting is given the default value specified in - * hook_field_storage_info(). - * - * @return \Drupal\field\Plugin\Core\Entity\Field - * The field entity. - * - * @throws Drupal\field\FieldException - * - * @deprecated as of Drupal 8.0. Use - * entity_create('field_entity', $definition)->save(). - * - * See: @link field Field API data structures @endlink. - */ -function field_create_field(array $field) { - $field = entity_create('field_entity', $field); - $field->save(); - return $field; -} - -/** - * Updates a field. - * - * Any module may forbid any update for any reason. For example, the - * field's storage module might forbid an update if it would change - * the storage schema while data for the field exists. A field type - * module might forbid an update if it would change existing data's - * semantics, or if there are external dependencies on field settings - * that cannot be updated. - * - * @param mixed $field - * Either the \Drupal\field\Plugin\Core\Entity\Field object to update, or a - * field array structure. If the latter, $field['field_name'] must provided; - * it identifies the field that will be updated to match this structure. Any - * other properties of the field that are not specified in $field will be left - * unchanged, so it is not necessary to pass in a fully populated $field - * structure. - * - * @throws Drupal\field\FieldException - * - * @deprecated as of Drupal 8.0. Use $field->save(). - * - * @see field_create_field() - */ -function field_update_field($field) { - // Module developers can still pass in an array of properties. - if (is_array($field)) { - $field_loaded = entity_load('field_entity', $field['field_name']); - if (empty($field_loaded)) { - throw new FieldException('Attempt to update a non-existent field.'); - } - // Merge incoming values. - foreach ($field as $key => $value) { - $field_loaded[$key] = $value; - } - $field = $field_loaded; - } - - $field->save(); -} - -/** * Reads a single field record directly from the database. * * Generally, you should use the field_info_field() instead. @@ -162,103 +79,6 @@ function field_read_fields($conditions = array(), $include_additional = array()) } /** - * Marks a field and its instances and data for deletion. - * - * @param $field_name - * The field name to delete. - * - * @deprecated as of Drupal 8.0. Use $field->delete(). - */ -function field_delete_field($field_name) { - if ($field = field_info_field($field_name)) { - $field->delete(); - } -} - -/** - * Creates an instance of a field, binding it to a bundle. - * - * @param array $instance - * A field instance definition array. The field_name, entity_type and - * bundle properties are required. Other properties, if omitted, - * will be given the following default values: - * - label: the field name - * - description: empty string - * - required: FALSE - * - default_value_function: empty string - * - settings: each omitted setting is given the default value specified in - * hook_field_info(). - * - widget: - * - type: the default widget specified in hook_field_info(). - * - settings: each omitted setting is given the default value specified in - * hook_field_widget_info(). - * - * @return \Drupal\field\Plugin\Core\Entity\FieldInstance - * The field instance entity. - * - * @throws Drupal\field\FieldException - * - * @deprecated as of Drupal 8.0. Use - * entity_create('field_instance', $definition)->save(). - * - * See: @link field Field API data structures @endlink. - */ -function field_create_instance(array $instance) { - $instance = entity_create('field_instance', $instance); - $instance->save(); - return $instance; -} - -/** - * Updates an instance of a field. - * - * @param mixed $instance - * Either the \Drupal\field\Plugin\Core\Entity\FieldInstance to update, or an - * associative array representing an instance structure. If the latter, the - * required keys and values are: - * - entity_type: The type of the entity the field is attached to. - * - bundle: The bundle this field belongs to. - * - field_name: The name of an existing field. - * The other array elements represent properties of the instance, and all - * properties must be specified or their default values will be used (except - * internal-use properties, which are assigned automatically). To avoid losing - * the previously stored properties of the instance when making a change, - * first load the instance with field_info_instance(), then override the - * values you want to override, and finally save using this function. Example: - * @code - * // Fetch an instance info array. - * $instance_info = field_info_instance($entity_type, $field_name, $bundle_name); - * // Change a single property in the instance definition. - * $instance_info['definition']['required'] = TRUE; - * // Write the changed definition back. - * field_update_instance($instance_info['definition']); - * @endcode - * - * @throws Drupal\field\FieldException - * - * @deprecated as of Drupal 8.0. Use $instance->save(). - * - * @see field_info_instance() - * @see field_create_instance() - */ -function field_update_instance($instance) { - // Module developers can still pass in an array of properties. - if (is_array($instance)) { - $instance_loaded = entity_load('field_instance', $instance['entity_type'] . '.' . $instance['bundle'] . '.' . $instance['field_name']); - if (empty($instance_loaded)) { - throw new FieldException('Attempt to update a non-existent instance.'); - } - // Merge incoming values. - foreach ($instance as $key => $value) { - $instance_loaded[$key] = $value; - } - $instance = $instance_loaded; - } - - $instance->save(); -} - -/** * Reads a single instance record from the database. * * Generally, you should use field_info_instance() instead, as it provides @@ -317,22 +137,6 @@ function field_read_instances($conditions = array(), $include_additional = array } /** - * Marks a field instance and its data for deletion. - * - * @param \Drupal\field\Plugin\Core\Entity\FieldInstance $instance - * The field instance. - * @param $field_cleanup - * If TRUE, the field will be deleted as well if its last instance is being - * deleted. If FALSE, it is the caller's responsibility to handle the case of - * fields left without instances. Defaults to TRUE. - * - * @deprecated as of Drupal 8.0. Use $instance->delete(). - */ -function field_delete_instance(FieldInstance $instance, $field_cleanup = TRUE) { - $instance->delete($field_cleanup); -} - -/** * @} End of "defgroup field_crud". */