function entityform_entity_info in Entityform 7
Same name and namespace in other branches
- 7.2 entityform.module \entityform_entity_info()
Implement hook_entity_info().
We define two entities here - the actual entity that will hold our domain specific information and an entity that holds information about the different types of entities. See here: http://drupal.org/node/977380 for a discussion on this choice.
File
- ./
entityform.module, line 55 - Module for the Entityform Entity - a starting point to create your own Entity and associated administration interface
Code
function entityform_entity_info() {
$return['entityform'] = array(
'label' => t('Entityform'),
// The entity class and controller class extend the classes provided by the
// Entity API
'entity class' => 'Entityform',
'controller class' => 'EntityformController',
'base table' => 'entityform',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'entityform_id',
'bundle' => 'type',
),
// Bundles are defined by the entityform types below
'bundles' => array(),
// Bundle keys tell the FieldAPI how to extract information from the bundle objects
'bundle keys' => array(
'bundle' => 'type',
),
'view modes' => array(
'full' => array(
'label' => t('Full content'),
'custom settings' => FALSE,
),
'email' => array(
'label' => t('Email'),
'custom settings' => FALSE,
),
'confirmation' => array(
'label' => t('Confirmation'),
'custom settings' => FALSE,
),
'download' => array(
'label' => t('Downloads'),
'custom settings' => FALSE,
),
'table' => array(
'label' => t('Submissions Table'),
'custom settings' => FALSE,
),
),
'label callback' => 'entity_class_label',
'uri callback' => 'entityform_uri',
'creation callback' => 'entityform_create',
'access callback' => 'entityform_access',
'module' => 'entityform',
// The information below is used by the EntityformUIController (which extends the EntityDefaultUIController)
'admin ui' => array(
//@todo this goes to default submissions View, what do to if View is disabled?
'path' => 'admin/structure/entityforms/list',
'front path' => 'entityform',
'file' => 'entityform.admin.inc',
'controller class' => 'EntityformUIController',
'menu wildcard' => '%entityform',
),
'metadata controller class' => 'EntityformMetadataController',
'metatags' => FALSE,
);
// Add bundle info but bypass entity_load() as we cannot use it here.
$types = db_select('entityform_type', 'e')
->fields('e')
->execute()
->fetchAllAssoc('type');
foreach ($types as $type => $info) {
$return['entityform']['bundles'][$type] = array(
'label' => $info->label,
'admin' => array(
'path' => 'admin/structure/entityform_types/manage/%entityform_type',
'real path' => 'admin/structure/entityform_types/manage/' . $type,
'bundle argument' => 4,
'access arguments' => array(
'administer entityform types',
),
),
);
}
// The entity that holds information about the entity types
$return['entityform_type'] = array(
'label' => t('Entityform Type'),
'entity class' => 'EntityformType',
'controller class' => 'EntityformTypeController',
'base table' => 'entityform_type',
'fieldable' => FALSE,
'bundle of' => 'entityform',
'exportable' => TRUE,
'entity keys' => array(
'id' => 'id',
'name' => 'type',
'label' => 'label',
),
'view modes' => array(
'full' => array(
'label' => t('Full content'),
'custom settings' => FALSE,
),
),
'access callback' => 'entityform_type_access',
'module' => 'entityform',
// Enable the entity API's admin UI.
'admin ui' => array(
'path' => 'admin/structure/entityform_types',
'file' => 'entityform_type.admin.inc',
'controller class' => 'EntityformTypeUIController',
),
'metadata controller class' => 'EntityformTypeMetadataController',
);
return $return;
}