You are here

function commerce_customer_entity_info in Commerce Core 7

Implements hook_entity_info().

File

modules/customer/commerce_customer.module, line 12
Defines the customer profile entity and API functions to manage customers and interact with them.

Code

function commerce_customer_entity_info() {
  $return = array(
    'commerce_customer_profile' => array(
      'label' => t('Commerce Customer profile'),
      'controller class' => 'CommerceCustomerProfileEntityController',
      'base table' => 'commerce_customer_profile',
      'revision table' => 'commerce_customer_profile_revision',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'profile_id',
        'revision' => 'revision_id',
        'bundle' => 'type',
      ),
      'bundle keys' => array(
        'bundle' => 'type',
      ),
      'bundles' => array(),
      'load hook' => 'commerce_customer_profile_load',
      'view modes' => array(
        // Neither of these provide a full view of the profile but rather give
        // the summary of field data as seen on the checkout form or in the
        // customer profile reference field's display formatter.
        'administrator' => array(
          'label' => t('Administrator'),
          'custom settings' => FALSE,
        ),
        'customer' => array(
          'label' => t('Customer'),
          'custom settings' => FALSE,
        ),
      ),
      'uri callback' => 'commerce_customer_profile_uri',
      'label callback' => 'commerce_customer_profile_label',
      'token type' => 'commerce-customer-profile',
      'metadata controller class' => '',
      'access callback' => 'commerce_entity_access',
      'access arguments' => array(
        'user key' => 'uid',
        'access tag' => 'commerce_customer_profile_access',
      ),
      'permission labels' => array(
        'singular' => t('customer profile'),
        'plural' => t('customer profiles'),
      ),
      // Prevent Redirect alteration of the customer form.
      'redirect' => FALSE,
    ),
  );
  foreach (commerce_customer_profile_type_get_name() as $type => $name) {
    $return['commerce_customer_profile']['bundles'][$type] = array(
      'label' => $name,
    );
  }
  return $return;
}