function biblio_entity_info in Bibliography Module 7.3
Same name and namespace in other branches
- 7.2 biblio.module \biblio_entity_info()
Implements hook_entity_info().
Inform the Drupal and the Field API about entity types. Uses the contrib Entity API module to create entities
File
- ./
biblio.module, line 259 - Maintains bibliographic lists.
Code
function biblio_entity_info() {
$return['biblio'] = array(
'label' => t('Biblio'),
'entity class' => 'Biblio',
'controller class' => 'EntityAPIController',
'base table' => 'biblio',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'bid',
'bundle' => 'type',
'label' => 'title',
),
'bundle keys' => array(
'bundle' => 'type',
),
'load hook' => 'biblio_load',
'view modes' => array(
'full' => array(
'label' => t('Full content'),
'custom settings' => FALSE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => TRUE,
),
),
// Entity API label callback that takes a look at our entity class method defaultLabel()
'label callback' => 'entity_class_label',
// This is also a standard Entity API callback for uri.
// It executes our entity defaultUri() method
'uri callback' => 'entity_class_uri',
'module' => 'biblio',
'access callback' => 'biblio_access',
'views controller class' => 'BiblioViewsController',
'metadata controller class' => 'BiblioMetadataController',
);
// @todo: Biblio 1.x had a biblio type called "Biblio" if type was 0.
$return['biblio']['bundles']['biblio'] = array(
'label' => 'Biblio',
);
if (db_table_exists('biblio_type') && ($bundles = biblio_types())) {
foreach ($bundles as $bundle) {
$return['biblio']['bundles'][$bundle->type] = array(
'label' => $bundle->name,
);
}
}
$return['biblio_contributor'] = array(
'label' => t('Contributor'),
'entity class' => 'BiblioContributor',
'controller class' => 'EntityAPIController',
'base table' => 'biblio_contributor',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'cid',
'label' => 'name',
),
'bundles' => array(
'contributor' => array(
'label' => t('Contributor'),
),
),
'load hook' => 'biblio_contributor_load',
'view modes' => array(
'full' => array(
'label' => t('Full'),
'custom settings' => FALSE,
),
),
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
'module' => 'biblio',
'access callback' => 'biblio_contributor_access',
'inline entity form' => array(
'controller' => 'BiblioContributorInlineEntityFormController',
),
);
return $return;
}