hook_field_storage_details

function hook_field_storage_details

hook_field_storage_details($field)

Reveal the internal details about the storage for a field.

For example, an SQL storage module might return the Schema API structure for the table. A key/value storage module might return the server name, authentication credentials, and bin name.

Field storage modules are not obligated to implement this hook. Modules that rely on these details must only use them for read operations.

Parameters

$field: A field structure.

Return value

An array of details.

  • The first dimension is a store type (sql, solr, etc).
  • The second dimension indicates the age of the values in the store FIELD_LOAD_CURRENT or FIELD_LOAD_REVISION.
  • Other dimensions are specific to the field storage module.

See also

hook_field_storage_details_alter()

Related topics

File

modules/field/field.api.php, line 1712
Hooks provided by the Field module.

Code

function hook_field_storage_details($field) {
  $details = array();

  // Add field columns.
  foreach ((array) $field['columns'] as $column_name => $attributes) {
    $real_name = _field_sql_storage_columnname($field['field_name'], $column_name);
    $columns[$column_name] = $real_name;
  }
  return array(
    'sql' => array(
      FIELD_LOAD_CURRENT => array(
        _field_sql_storage_tablename($field) => $columns,
      ),
      FIELD_LOAD_REVISION => array(
        _field_sql_storage_revision_tablename($field) => $columns,
      ),
    ),
  );
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_storage_details/7.x

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部