You are here

function file_entity_entity_info_alter in File Entity (fieldable files) 7

Same name and namespace in other branches
  1. 7.3 file_entity.module \file_entity_entity_info_alter()
  2. 7.2 file_entity.module \file_entity_entity_info_alter()

Implements hook_entity_info_alter().

Extends the core file entity to be fieldable. Modules can define file types via hook_file_type_info(). For each defined type, create a bundle, so that fields can be configured per file type.

File

./file_entity.module, line 213
Extends Drupal file entities to be fieldable and viewable.

Code

function file_entity_entity_info_alter(&$entity_info) {
  $entity_info['file']['fieldable'] = TRUE;
  $entity_info['file']['entity keys']['bundle'] = 'type';
  $entity_info['file']['bundles'] = array();
  $entity_info['file']['view modes']['full'] = array(
    'label' => t('Full'),
    'custom settings' => FALSE,
  );
  foreach (file_info_file_types() as $type => $info) {
    $info += array(
      // Provide a default administration path for Field UI, but not if 'admin'
      // has been explicitly set to NULL.
      'admin' => array(
        'path' => 'admin/config/media/file-types/manage/%',
        'real path' => 'admin/config/media/file-types/manage/' . $type,
        'bundle argument' => 5,
      ),
    );
    $entity_info['file']['bundles'][$type] = array_intersect_key($info, drupal_map_assoc(array(
      'label',
      'admin',
    )));
    $entity_info['file']['view callback'] = 'file_view_multiple';
  }
}