function config_pages_entity_info in Config Pages 7
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
- ./
config_pages.module, line 164 - This module is based on Model module (https://drupal.org/project/model) and most of the comments left untouched but have entity types renamed. Suuport for features added.
Code
function config_pages_entity_info() {
$return['config_pages'] = array(
'label' => t('ConfigPages'),
// The entity class and controller class extend the classes provided by the
// Entity API
'entity class' => 'ConfigPages',
'controller class' => 'ConfigPagesController',
'base table' => 'config_pages',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'config_pages_id',
'bundle' => 'type',
),
// Bundles are defined by the config_pages types below
'bundles' => array(),
// Bundle keys tell the FieldAPI how to extract information from the bundle objects
'bundle keys' => array(
'bundle' => 'type',
),
'label callback' => 'entity_class_label',
'uri callback' => 'entity_class_uri',
'creation callback' => 'config_pages_create',
'access callback' => 'config_pages_access',
'module' => 'config_pages',
// The information below is used by the ConfigPagesUIController (which extends the EntityDefaultUIController)
'admin ui' => array(
'path' => 'config_pagess',
'file' => 'config_pages.admin.inc',
'controller class' => 'ConfigPagesUIController',
'menu wildcard' => '%config_pages',
),
'redirect' => FALSE,
'view modes' => array(
'full' => array(
'label' => t('Full content'),
'custom settings' => FALSE,
),
),
);
// The entity that holds information about the entity types
$return['config_pages_type'] = array(
'label' => t('Config Page'),
'entity class' => 'ConfigPagesType',
'controller class' => 'ConfigPagesTypeController',
'base table' => 'config_pages_type',
'fieldable' => FALSE,
'bundle of' => 'config_pages',
'exportable' => TRUE,
'entity keys' => array(
'id' => 'id',
'name' => 'type',
'label' => 'label',
),
'access callback' => 'config_pages_type_access',
'module' => 'config_pages',
// Enable the entity API's admin UI.
'admin ui' => array(
'path' => CONFIG_PAGES_PATH_MANAGE_TYPES,
'file' => 'config_pages.type.admin.inc',
'controller class' => 'ConfigPagesTypeUIController',
),
);
foreach (_config_pages_get_names() as $type => $info) {
$return['config_pages']['bundles'][$type] = array(
'label' => $info->label,
'admin' => array(
'path' => CONFIG_PAGES_PATH_MANAGE_TYPES . '/manage/%config_pages_type',
'real path' => CONFIG_PAGES_PATH_MANAGE_TYPES . '/manage/' . $type,
'bundle argument' => 5,
'access arguments' => array(
'administer config_pages types',
),
),
);
}
return $return;
}