- Patch #445044 by bjaspan, Damien Tournoud, chx, Berdir: remove the field autoload feature.

merge-requests/26/head
Dries Buytaert 2009-06-05 18:25:41 +00:00
parent 9079d78481
commit 57fe0ca1e9
4 changed files with 44 additions and 66 deletions

View File

@ -72,10 +72,6 @@ define('FIELD_STORAGE_INSERT', 'insert');
* @} End of "defgroup field_storage"
*/
/**
* @autoload field_attach_.* field_attach FieldException {
*/
/**
* @defgroup field_attach Field Attach API
* @{
@ -278,13 +274,6 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$
return _field_invoke_multiple($op, $obj_type, $objects, $a, $b, TRUE);
}
/**
* @} End of "defgroup field_attach"
*
* The rest of the functions in this file are not in a group, but
* their automatically-generated autoloaders are (see field.autoload.inc).
*/
/**
* Add form elements for all fields for an object to a form structure.
*
@ -301,7 +290,7 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$
* TODO : document the resulting $form structure, like we do for
* field_attach_view().
*/
function _field_attach_form($obj_type, $object, &$form, $form_state) {
function field_attach_form($obj_type, $object, &$form, $form_state) {
// TODO : something's not right here : do we alter the form or return a value ?
$form += (array) _field_invoke_default('form', $obj_type, $object, $form, $form_state);
@ -331,7 +320,7 @@ function _field_attach_form($obj_type, $object, &$form, $form_state) {
* Loaded field values are added to $objects. Fields with no values should be
* set as an empty array.
*/
function _field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
function field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
$load_current = $age == FIELD_LOAD_CURRENT;
$info = field_info_fieldable_types($obj_type);
@ -421,7 +410,7 @@ function _field_attach_load($obj_type, $objects, $age = FIELD_LOAD_CURRENT) {
* On return, the objects in $objects are modified by having the
* appropriate set of fields added.
*/
function _field_attach_load_revision($obj_type, $objects) {
function field_attach_load_revision($obj_type, $objects) {
return field_attach_load($obj_type, $objects, FIELD_LOAD_REVISION);
}
@ -440,7 +429,7 @@ function _field_attach_load_revision($obj_type, $objects) {
* @return
* Throws a FieldValidationException if validation errors are found.
*/
function _field_attach_validate($obj_type, $object) {
function field_attach_validate($obj_type, $object) {
$errors = array();
_field_invoke_default('validate', $obj_type, $object, $errors);
_field_invoke('validate', $obj_type, $object, $errors);
@ -484,7 +473,7 @@ function _field_attach_validate($obj_type, $object) {
* @param $form_state
* An associative array containing the current state of the form.
*/
function _field_attach_form_validate($obj_type, $object, $form, &$form_state) {
function field_attach_form_validate($obj_type, $object, $form, &$form_state) {
// Extract field values from submitted values.
_field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state);
@ -516,7 +505,7 @@ function _field_attach_form_validate($obj_type, $object, $form, &$form_state) {
* @param $form_state
* An associative array containing the current state of the form.
*/
function _field_attach_submit($obj_type, $object, $form, &$form_state) {
function field_attach_submit($obj_type, $object, $form, &$form_state) {
// Extract field values from submitted values.
_field_invoke_default('extract_form_values', $obj_type, $object, $form, $form_state);
@ -540,7 +529,7 @@ function _field_attach_submit($obj_type, $object, $form, &$form_state) {
* @param $object
* The object with fields to process.
*/
function _field_attach_presave($obj_type, $object) {
function field_attach_presave($obj_type, $object) {
// TODO : to my knowledge, no field module has any use for 'presave' on D6.
// should we keep this ?
_field_invoke('presave', $obj_type, $object);
@ -568,7 +557,7 @@ function _field_attach_presave($obj_type, $object) {
* Default values (if any) will be added to the $object parameter for fields
* it leaves unspecified.
*/
function _field_attach_insert($obj_type, $object) {
function field_attach_insert($obj_type, $object) {
_field_invoke_default('insert', $obj_type, $object);
_field_invoke('insert', $obj_type, $object);
@ -597,7 +586,7 @@ function _field_attach_insert($obj_type, $object) {
* @param $object
* The object with fields to save.
*/
function _field_attach_update($obj_type, $object) {
function field_attach_update($obj_type, $object) {
_field_invoke('update', $obj_type, $object);
// Let other modules act on updating the object, accumulating saved
@ -626,7 +615,7 @@ function _field_attach_update($obj_type, $object) {
* @param $object
* The object whose field data to delete.
*/
function _field_attach_delete($obj_type, $object) {
function field_attach_delete($obj_type, $object) {
_field_invoke('delete', $obj_type, $object);
module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_delete', $obj_type, $object);
@ -651,7 +640,7 @@ function _field_attach_delete($obj_type, $object) {
* @param $object
* The object with fields to save.
*/
function _field_attach_delete_revision($obj_type, $object) {
function field_attach_delete_revision($obj_type, $object) {
_field_invoke('delete revision', $obj_type, $object);
module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_delete_revision', $obj_type, $object);
@ -677,7 +666,7 @@ function _field_attach_delete_revision($obj_type, $object) {
* @return
* A structured content array tree for drupal_render().
*/
function _field_attach_view($obj_type, $object, $teaser = FALSE) {
function field_attach_view($obj_type, $object, $teaser = FALSE) {
// Let field modules sanitize their data for output.
_field_invoke('sanitize', $obj_type, $object);
@ -697,7 +686,7 @@ function _field_attach_view($obj_type, $object, $teaser = FALSE) {
* containing the themed output for the whole field.
* - Adds the formatted values in the 'view' key of the items.
*/
function _field_attach_preprocess($obj_type, $object) {
function field_attach_preprocess($obj_type, $object) {
return _field_invoke_default('preprocess', $obj_type, $object);
}
@ -706,7 +695,7 @@ function _field_attach_preprocess($obj_type, $object) {
*
* TODO D7: We do not yet know if this really belongs in Field API.
*/
function _field_attach_prepare_translation($node) {
function field_attach_prepare_translation($node) {
// Prevent against invalid 'nodes' built by broken 3rd party code.
if (isset($node->type)) {
$type = content_types($node->type);
@ -730,7 +719,7 @@ function _field_attach_prepare_translation($node) {
* @param $bundle
* The name of the newly created bundle.
*/
function _field_attach_create_bundle($bundle) {
function field_attach_create_bundle($bundle) {
module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_create_bundle', $bundle);
// Clear the cache.
@ -750,7 +739,7 @@ function _field_attach_create_bundle($bundle) {
* @param $bundle_new
* The new name of the bundle.
*/
function _field_attach_rename_bundle($bundle_old, $bundle_new) {
function field_attach_rename_bundle($bundle_old, $bundle_new) {
module_invoke(variable_get('field_storage_module', 'field_sql_storage'), 'field_storage_rename_bundle', $bundle_old, $bundle_new);
db_update('field_config_instance')
->fields(array('bundle' => $bundle_new))
@ -779,7 +768,7 @@ function _field_attach_rename_bundle($bundle_old, $bundle_new) {
* @param $bundle
* The bundle to delete.
*/
function _field_attach_delete_bundle($bundle) {
function field_attach_delete_bundle($bundle) {
// Delete the instances themseves
$instances = field_info_instances($bundle);
foreach ($instances as $instance) {
@ -809,7 +798,7 @@ function _field_attach_delete_bundle($bundle) {
* 2: bundle name of the object
* 3: whether $obj_type's fields should be cached (TRUE/FALSE)
*/
function _field_attach_extract_ids($object_type, $object) {
function field_attach_extract_ids($object_type, $object) {
// TODO D7 : prevent against broken 3rd party $node without 'type'.
$info = field_info_fieldable_types($object_type);
// Objects being created might not have id/vid yet.
@ -823,5 +812,5 @@ function _field_attach_extract_ids($object_type, $object) {
}
/**
* @autoload} End of "@autoload field_attach"
* @} End of "defgroup field_attach"
*/

View File

@ -11,6 +11,5 @@ files[] = field.info.inc
files[] = field.default.inc
files[] = field.attach.inc
files[] = field.form.inc
files[] = field.autoload.inc
dependencies[] = field_sql_storage
required = TRUE

View File

@ -196,17 +196,6 @@ function _field_info_collate_fields($reset = FALSE) {
return $info;
}
/**
* @} End of "defgroup field_info"
*
* The rest of the functions in this file are not in a group, but
* their automatically-generated autoloaders are (see field.autoload.inc).
*/
/**
* @autoload field_(?:behaviors|info)_.* field_info FieldException {
*/
/**
* Helper function for determining the behavior of a field
* with respect to a given operation.
@ -222,7 +211,7 @@ function _field_info_collate_fields($reset = FALSE) {
* FIELD_BEHAVIOR_CUSTOM - use the field's callback function.
* FIELD_BEHAVIOR_DEFAULT - use field.module default behavior.
*/
function _field_behaviors_field($op, $field) {
function field_behaviors_field($op, $field) {
$info = field_info_field_types($field['type']);
return isset($info['behaviors'][$op]) ? $info['behaviors'][$op] : FIELD_BEHAVIOR_DEFAULT;
}
@ -241,7 +230,7 @@ function _field_behaviors_field($op, $field) {
* FIELD_BEHAVIOR_CUSTOM - use the widget's callback function.
* FIELD_BEHAVIOR_DEFAULT - use field.module default behavior.
*/
function _field_behaviors_widget($op, $instance) {
function field_behaviors_widget($op, $instance) {
$info = field_info_widget_types($instance['widget']['type']);
return isset($info['behaviors'][$op]) ? $info['behaviors'][$op] : FIELD_BEHAVIOR_DEFAULT;
}
@ -260,7 +249,7 @@ function _field_behaviors_widget($op, $instance) {
* FIELD_BEHAVIOR_CUSTOM - use the formatter's callback function.
* FIELD_BEHAVIOR_DEFAULT - use field module default behavior.
*/
function _field_behaviors_formatter($op, $display) {
function field_behaviors_formatter($op, $display) {
$info = field_info_formatter_types($display['type']);
return isset($info['behaviors'][$op]) ? $info['behaviors'][$op] : FIELD_BEHAVIOR_DEFAULT;
}
@ -275,7 +264,7 @@ function _field_behaviors_formatter($op, $display) {
* Either a field type description, as provided by hook_field_info(), or an
* array of all existing field types, keyed by field type name.
*/
function _field_info_field_types($field_type = NULL) {
function field_info_field_types($field_type = NULL) {
$info = _field_info_collate_types();
$field_types = $info['field types'];
if ($field_type) {
@ -299,7 +288,7 @@ function _field_info_field_types($field_type = NULL) {
* hook_field_widget_info(), or an array of all existing widget
* types, keyed by widget type name.
*/
function _field_info_widget_types($widget_type = NULL) {
function field_info_widget_types($widget_type = NULL) {
$info = _field_info_collate_types();
$widget_types = $info['widget types'];
if ($widget_type) {
@ -322,7 +311,7 @@ function _field_info_widget_types($widget_type = NULL) {
* Either a formatter type description, as provided by hook_field_formatter_info(),
* or an array of all existing widget types, keyed by widget type name.
*/
function _field_info_formatter_types($formatter_type = NULL) {
function field_info_formatter_types($formatter_type = NULL) {
$info = _field_info_collate_types();
$formatter_types = $info['formatter types'];
if ($formatter_type) {
@ -345,7 +334,7 @@ function _field_info_formatter_types($formatter_type = NULL) {
* Either a fieldable type description, as provided by hook_fieldable_info(),
* or an array of all existing fieldable types, keyed by fieldable type name.
*/
function _field_info_fieldable_types($obj_type = NULL) {
function field_info_fieldable_types($obj_type = NULL) {
$info = _field_info_collate_types();
$fieldable_types = $info['fieldable types'];
if ($obj_type) {
@ -362,7 +351,7 @@ function _field_info_fieldable_types($obj_type = NULL) {
* Return an array of fieldable bundle names and labels, for an individual
* object type or for all object types.
*/
function _field_info_bundles($obj_type = NULL) {
function field_info_bundles($obj_type = NULL) {
$info = _field_info_collate_types();
$bundles = array();
foreach ($info['fieldable types'] as $type => $fieldable_info) {
@ -378,7 +367,7 @@ function _field_info_bundles($obj_type = NULL) {
* // TODO : might not be needed depending on how we solve
* // the 'namespace bundle names' issue
*/
function _field_info_bundle_entity($bundle) {
function field_info_bundle_entity($bundle) {
$info = _field_info_collate_types();
foreach ($info['fieldable types'] as $type => $fieldable_info) {
if (isset($fieldable_info['bundles'][$bundle])) {
@ -396,7 +385,7 @@ function _field_info_bundle_entity($bundle) {
* property, bundles, which is an array of all the bundles to which
* this field belongs.
*/
function _field_info_fields() {
function field_info_fields() {
$info = _field_info_collate_fields();
return $info['fields'];
}
@ -411,7 +400,7 @@ function _field_info_fields() {
* property, bundles, which is an array of all the bundles to which
* this field belongs.
*/
function _field_info_field($field_name) {
function field_info_field($field_name) {
$info = _field_info_collate_fields();
if (isset($info['fields'][$field_name])) {
return $info['fields'][$field_name];
@ -425,7 +414,7 @@ function _field_info_field($field_name) {
* @param $bundle_name
* If set, return information on just this bundle.
*/
function _field_info_instances($bundle_name = NULL) {
function field_info_instances($bundle_name = NULL) {
$info = _field_info_collate_fields();
if (!isset($bundle_name)) {
return $info['instances'];
@ -439,7 +428,7 @@ function _field_info_instances($bundle_name = NULL) {
/**
* Return an array of instance data for a specific field and bundle.
*/
function _field_info_instance($field_name, $bundle_name) {
function field_info_instance($field_name, $bundle_name) {
$info = _field_info_collate_fields();
if (isset($info['instances'][$bundle_name][$field_name])) {
return $info['instances'][$bundle_name][$field_name];
@ -455,7 +444,7 @@ function _field_info_instance($field_name, $bundle_name) {
* The field type's default settings, as provided by hook_field_info(), or an
* empty array.
*/
function _field_info_field_settings($type) {
function field_info_field_settings($type) {
$info = field_info_field_types($type);
return isset($info['settings']) ? $info['settings'] : array();
}
@ -469,7 +458,7 @@ function _field_info_field_settings($type) {
* The field type's default instance settings, as provided by
* hook_field_info(), or an empty array.
*/
function _field_info_instance_settings($type) {
function field_info_instance_settings($type) {
$info = field_info_field_types($type);
return isset($info['instance_settings']) ? $info['instance_settings'] : array();
}
@ -483,7 +472,7 @@ function _field_info_instance_settings($type) {
* The field type's default settings, as provided by hook_field_info(), or an
* empty array.
*/
function _field_info_widget_settings($type) {
function field_info_widget_settings($type) {
$info = field_info_widget_types($type);
return isset($info['settings']) ? $info['settings'] : array();
}
@ -497,11 +486,11 @@ function _field_info_widget_settings($type) {
* The field formatter's default settings, as provided by
* hook_field_info(), or an empty array.
*/
function _field_info_formatter_settings($type) {
function field_info_formatter_settings($type) {
$info = field_info_formatter_types($type);
return isset($info['settings']) ? $info['settings'] : array();
}
/**
* @autoload} End of "@autoload field_info"
* @} End of "defgroup field_info"
*/

View File

@ -6,12 +6,13 @@
*/
/*
* Load all Field API functions, either directly or via an
* autoloader. We can't do this during hook_init() because it isn't
* run during update.php.
* Load all public Field API functions. Drupal currently has no
* mechanism for auto-loading core APIs, so we have to load them on
* every page request.
*/
require(DRUPAL_ROOT . '/modules/field/field.crud.inc');
require(DRUPAL_ROOT . '/modules/field/field.autoload.inc');
require(DRUPAL_ROOT . '/modules/field/field.info.inc');
require(DRUPAL_ROOT . '/modules/field/field.attach.inc');
/**
* @defgroup field Field API
@ -108,8 +109,8 @@ function field_flush_caches() {
function field_help($path, $arg) {
switch ($path) {
case 'admin/help#field':
$output = '<p>' . t('The Field API allows custom data fields to be attached to Drupal objects and takes care of storing, loading, editing, and rendering field data. Any object type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it.') . '</p>';
$output .= '<p>' . t('The Field API provides no user interface on its own. Use the Content Construction Kit (CCK) contrib module to manage custom fields via a web browser.') . '</p>';
$output = '<p>' . t('The Field API allows custom data fields to be attached to Drupal objects and takes care of storing, loading, editing, and rendering field data. Any object type (node, user, etc.) can use the Field API to make itself "fieldable" and thus allow fields to be attached to it.') . '</p>';
$output .= '<p>' . t('The Field API provides no user interface on its own. Use the Content Construction Kit (CCK) contrib module to manage custom fields via a web browser.') . '</p>';
return $output;
}
}