function commerce_discount_entity_info in Commerce Discount 7
Implements hook_entity_info().
File
- ./
commerce_discount.module, line 183 - Defines the discount and discount offer entities, bundles and functionality.
Code
function commerce_discount_entity_info() {
$items['commerce_discount'] = array(
'label' => t('Commerce Discount'),
'controller class' => 'CommerceDiscountControllerExportable',
'entity class' => 'CommerceDiscount',
'base table' => 'commerce_discount',
'fieldable' => TRUE,
// For integration with Redirect module.
// @see http://drupal.org/node/1263884
'redirect' => FALSE,
'exportable' => TRUE,
'entity keys' => array(
'id' => 'discount_id',
'name' => 'name',
'label' => 'label',
'bundle' => 'type',
'status' => 'export_status',
),
'bundles' => array(),
'module' => 'commerce_discount',
'uri callback' => 'entity_class_uri',
'access callback' => 'commerce_discount_access',
'metadata controller class' => 'CommerceDiscountMetadataController',
'views controller class' => 'CommerceDiscountViewsController',
// Enable the entity API's admin UI.
'admin ui' => array(
'path' => 'admin/commerce/discounts',
'file' => 'includes/commerce_discount.admin.inc',
'controller class' => 'CommerceDiscountUIController',
),
);
foreach (commerce_discount_types() as $type => $info) {
$items['commerce_discount']['bundles'][$type] = array(
'label' => $info['label'],
);
}
$items['commerce_discount_offer'] = array(
'label' => t('Commerce Discount Offer'),
'controller class' => 'EntityAPIControllerExportable',
'entity class' => 'CommerceDiscountOffer',
'base table' => 'commerce_discount_offer',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'discount_offer_id',
'bundle' => 'type',
),
'bundles' => array(),
'module' => 'commerce_discount',
'metadata controller class' => 'EntityDefaultMetadataController',
'inline entity form' => array(
'controller' => 'CommerceDiscountOfferInlineEntityFormController',
),
);
foreach (commerce_discount_offer_types() as $type => $info) {
$items['commerce_discount_offer']['bundles'][$type] = array(
'label' => $info['label'],
);
}
return $items;
}