1 file.module | file_entity_info() |
Implements hook_entity_info().
File
- core/
modules/ file/ file.module, line 465 - Defines a "managed_file" Form API field and a "file" field for Field module.
Code
function file_entity_info() {
$bundles = array();
file_type_cache_reset();
foreach (file_type_get_types() as $type) {
$bundles[$type->type] = array(
'label' => $type->name,
'admin' => array(
'path' => 'admin/structure/file-types/manage/%file_type',
'real path' => 'admin/structure/file-types/manage/' . str_replace('_', '-', $type->type),
'bundle argument' => 4,
'access arguments' => array('administer file types'),
),
);
}
$entity_info = array(
'file' => array(
'label' => t('File'),
'bundle label' => t('Type'),
'base table' => 'file_managed',
'controller class' => 'FileStorageController',
'fieldable' => TRUE,
'entity class' => 'File',
'entity keys' => array(
'id' => 'fid',
'bundle' => 'type'
),
'bundle keys' => array(
'bundle' => 'type'
),
'bundles' => $bundles,
'uri callback' => 'file_uri',
'view modes' => array(
'teaser' => array(
'label' => t('Teaser'),
),
'full' => array(
'label' => t('Full content'),
),
'preview' => array(
'label' => t('Preview'),
'custom settings' => TRUE,
),
),
'static cache' => FALSE,
),
);
// If the cache table has been created, then enable entity caching.
if (db_table_exists('cache_entity_file')) {
$entity_info['file']['entity cache'] = TRUE;
$entity_info['file']['field cache'] = FALSE;
}
return $entity_info;
}