You are here

function eck__entity_type__info in Entity Construction Kit (ECK) 7

Same name and namespace in other branches
  1. 7.3 eck.entity_type.inc \eck__entity_type__info()
  2. 7.2 eck.entity_type.inc \eck__entity_type__info()

Generate the entity info for a specific entity

Parameters

$entity_type: (Object) as returned by eck__entity_type__load

1 call to eck__entity_type__info()
eck_entity_info in ./eck.module
Implements hook_entity_info().

File

./eck.entity_type.inc, line 551
ENTITY TYPE

Code

function eck__entity_type__info($entity_type) {
  module_load_include('inc', 'eck', 'eck.bundle');
  $info = array();
  $entity_type_label = $entity_type->label;
  if (!drupal_autoload_class($entity_class = eck_get_class_name($entity_type->name, 'Entity'))) {
    $entity_class = 'EckEntity';
  }
  if (!drupal_autoload_class($controller_class = eck_get_class_name($entity_type->name, 'Controller'))) {
    $controller_class = 'EckController';
  }
  $info[$entity_type->name] = array(
    'label' => t($entity_type_label),
    'base table' => "eck_{$entity_type->name}",
    'entity class' => $entity_class,
    'controller class' => $controller_class,
    'module' => 'eck',
    'fieldable' => TRUE,
    'entity keys' => array(
      'id' => 'id',
      'bundle' => 'type',
    ),
    'label callback' => 'eck__entity__label',
    'uri callback' => 'eck__entity__uri',
    // Bundles are defined by the entity types below.
    'bundles' => array(),
    // Bundle keys tell the FieldAPI how to extract information from the bundle objects.
    'bundle keys' => array(
      'bundle' => 'type',
    ),
    // I guess we need at least one view mode for entity_view_modes (the module) to work.
    'view modes' => array(
      'teaser' => array(
        'label' => t('Teaser'),
        'custom settings' => TRUE,
      ),
    ),
  );
  foreach (eck__bundle__load($entity_type->name) as $bundle) {
    $bundle_label = $bundle->label;
    $path = "admin/structure/eck/{$entity_type->name}/{$bundle->name}";
    $info[$entity_type->name]['bundles'][$bundle->name] = array(
      'label' => $bundle_label,
      'admin' => array(
        'path' => $path,
        'access arguments' => array(
          'administer entities',
        ),
      ),
      'crud' => array(
        'add' => array(
          'path' => $path . "/add",
        ),
        'edit' => array(
          'path' => $path . "/%/edit",
          'entity_id' => 5,
        ),
        'delete' => array(
          'path' => $path . "/%/delete",
          'entity_id' => 5,
        ),
        'view' => array(
          'path' => "{$entity_type->name}/{$bundle->name}/%",
          'entity_id' => 2,
        ),
      ),
    );
  }
  return $info;
}