You are here

function asset_entity_info in Asset 7

Implements hook_entity_info().

File

./asset.module, line 18
Asset module.

Code

function asset_entity_info() {
  $return = array(
    'asset' => array(
      'label' => t('Media Asset'),
      'plural label' => t('Media Assets'),
      'label callback' => 'entity_class_label',
      'access callback' => 'assets_entity_access_callback',
      'entity class' => 'Asset',
      'controller class' => 'EntityAPIController',
      'views controller class' => 'AssetViewsController',
      'inline entity form' => array(
        'controller' => 'AssetInlineEntityFormController',
      ),
      'base table' => 'asset',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'aid',
        'bundle' => 'type',
        'label' => 'title',
      ),
      'uri callback' => 'entity_class_uri',
      'static cache' => TRUE,
      'field cache' => TRUE,
      'view modes' => array(
        'full' => array(
          'label' => t('Full size'),
          'custom settings' => TRUE,
        ),
        'small' => array(
          'label' => t('Small'),
          'custom settings' => FALSE,
        ),
        'tooltip' => array(
          'label' => t('Tooltip'),
          'custom settings' => FALSE,
        ),
      ),
      'bundle keys' => array(
        'bundle' => 'type',
      ),
      'bundles' => array(),
      'module' => 'asset',
      'admin ui' => array(
        'path' => 'admin/content/assets',
        'file' => 'includes/asset.admin.inc',
        'controller class' => 'AssetsUIController',
      ),
    ),
    'asset_type' => array(
      'label' => t('Asset type'),
      'plural label' => t('Asset types'),
      'access callback' => 'assets_type_entity_access_callback',
      'entity class' => 'AssetType',
      'controller class' => 'EntityAPIControllerExportable',
      'base table' => 'asset_type',
      'bundle of' => 'asset',
      'exportable' => TRUE,
      'entity keys' => array(
        'id' => 'id',
        'name' => 'type',
        'label' => 'name',
      ),
      'module' => 'asset',
      'admin ui' => array(
        'path' => 'admin/structure/assets',
        'file' => 'includes/asset.admin.inc',
      ),
    ),
  );

  // Add bundle info but bypass entity_load() as we cannot use it here.
  $types = db_select('asset_type', 'at')
    ->fields('at')
    ->execute()
    ->fetchAllAssoc('type');
  foreach ($types as $type_name => $type) {
    $return['asset']['bundles'][$type_name] = array(
      'label' => $type->name,
      'admin' => array(
        'path' => 'admin/structure/assets/manage/%asset_type',
        'real path' => 'admin/structure/assets/manage/' . $type_name,
        'bundle argument' => 4,
        'access arguments' => array(
          'administer assets',
        ),
      ),
    );
  }
  return $return;
}