function ctools_export_get_schema

Get the schema for a given table.

This looks for data the export subsystem needs and applies defaults so that it's easily available.

27 calls to ctools_export_get_schema()
ctools_export_crud_delete in includes/export.inc
Delete a single exportable object.
ctools_export_crud_export in includes/export.inc
Get the exported code of a single exportable object.
ctools_export_crud_import in includes/export.inc
Turn exported code into an object.
ctools_export_crud_load in includes/export.inc
Load a single exportable object.
ctools_export_crud_load_all in includes/export.inc
Load all exportable objects of a given type.

... See full list

File

includes/export.inc, line 985

Code

function ctools_export_get_schema($table) {
    static $drupal_static_fast;
    if (!isset($drupal_static_fast)) {
        $drupal_static_fast['cache'] =& drupal_static(__FUNCTION__);
    }
    $cache =& $drupal_static_fast['cache'];
    if (empty($cache[$table])) {
        $schema = drupal_get_schema($table);
        // If our schema isn't loaded, it's possible we're in a state where it
        // simply hasn't been cached. If we've been asked, let's force the
        // issue.
        if (!$schema || empty($schema['export'])) {
            // Force a schema reset:
            $schema = drupal_get_schema($table, TRUE);
        }
        if (!isset($schema['export'])) {
            return array();
        }
        if (empty($schema['module'])) {
            return array();
        }
        // Add some defaults.
        $schema['export'] += array(
            'key' => 'name',
            'key name' => 'Name',
            'object' => 'stdClass',
            'status' => 'default_' . $table,
            'default hook' => 'default_' . $table,
            'can disable' => TRUE,
            'identifier' => $table,
            'primary key' => !empty($schema['primary key']) ? $schema['primary key'][0] : '',
            'bulk export' => TRUE,
            'list callback' => "{$schema['module']}_{$table}_list",
            'to hook code callback' => "{$schema['module']}_{$table}_to_hook_code",
            'cache defaults' => FALSE,
            'default cache bin' => 'cache',
            'export type string' => 'type',
            'boolean' => TRUE,
        );
        // If the export definition doesn't have the "primary key" then the CRUD
        // save callback won't work.
        if (empty($schema['export']['primary key']) && user_access('administer site configuration')) {
            drupal_set_message(t('The export definition of @table is missing the "primary key" property.', array(
                '@table' => $table,
            )), 'error');
        }
        // Notes:
        // The following callbacks may be defined to override default behavior
        // when using CRUD functions:
        //
        // create callback
        // load callback
        // load multiple callback
        // load all callback
        // save callback
        // delete callback
        // export callback
        // import callback
        //
        // See the appropriate ctools_export_crud function for details on what
        // arguments these callbacks should accept. Please do not call these
        // directly, always use the ctools_export_crud_* wrappers to ensure
        // that default implementations are honored.
        $cache[$table] = $schema;
    }
    return $cache[$table];
}