You are here

function file_entity_entity_info_alter in D7 Media 7

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/file_entity.module, line 121
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']['bundle keys']['bundle'] = 'type';
  $entity_info['file']['bundles'] = array();
  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/%file_type',
        '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',
    )));
  }
}