function biblio_entity_info in Bibliography Module 7.2
Same name and namespace in other branches
- 7.3 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 2556
Code
function biblio_entity_info() {
$return['biblio'] = array(
'label' => t('Biblio'),
'entity class' => 'Biblio',
'controller class' => 'BiblioController',
'views controller class' => 'EntityDefaultViewsController',
'base table' => 'biblio',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'bid',
'bundle' => biblio_bundle_name('biblio'),
),
'bundle keys' => array(
'bundle' => biblio_bundle_name('biblio'),
),
'static cache' => TRUE,
// Will be retrieved using biblio_types()
'bundles' => array(),
'load hook' => 'biblio_load',
// @todo: implement biblio node view modes. See http://drupal.org/node/1537320
'view modes' => array(
'full' => array(
'label' => t('Full Content'),
// Indicates whether or not the Field UI should allow field formatters to
// be configured separately for that view mode by default.
'custom settings' => FALSE,
),
'teaser' => array(
'label' => t('Teaser'),
'custom settings' => FALSE,
),
),
// 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_entity_access',
);
// Since we have multiple bundles, we will need to tell the Field API what
// bundles we have and what paths to put the extra field management interfaces
// for our entity. To do that, we define, for each of our bundles, a label
// that is shown to the user and the menu information that the Field API will
// need to add itself to the menu.
$publication_types = biblio_types('biblio');
if (!empty($publication_types)) {
foreach ($publication_types as $type => $info) {
$return['biblio']['bundles'][$type] = array(
'label' => $info->name,
'admin' => array(
// defines the path that should be used in hook_menu() for the Fields UI pages
'path' => 'admin/structure/biblio/publication-types/%biblio_bundle',
// The exact path that should be used when generating links within the admin interface
'real path' => 'admin/structure/biblio/publication-types/' . str_replace('_', '-', $type),
// menu args are 0 based, so is the seventh part of the path, which
// here is %biblio_bundle.
'bundle argument' => 4,
'access arguments' => array(
'manage biblio structure',
),
),
);
}
}
$return['biblio_contributor'] = array(
'label' => t('Contributor'),
'entity class' => 'BiblioContributor',
'controller class' => 'BiblioContributorController',
'base table' => 'biblio_contributor',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'cid',
'bundle' => biblio_bundle_name('biblio_contributor'),
'label' => 'title',
),
'bundle keys' => array(
'bundle' => biblio_bundle_name('biblio_contributor'),
),
// @todo: possibly figure out a better bundle name and/or figure out what
// bundles we can have for contributors
'bundles' => array(),
'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_entity_access',
);
$contributor_categories = biblio_types('biblio_contributor');
if (!empty($contributor_categories)) {
foreach ($contributor_categories as $type => $info) {
$return['biblio_contributor']['bundles'][$type] = array(
'label' => $info->name,
'admin' => array(
'path' => 'admin/structure/biblio/contributors/%contributor_bundle',
'real path' => 'admin/structure/biblio/contributors/' . str_replace('_', '-', $type),
'bundle argument' => 4,
'access arguments' => array(
'manage biblio structure',
),
),
);
}
}
return $return;
}