You are here

function eck__entity_type__info in Entity Construction Kit (ECK) 7.3

Same name and namespace in other branches
  1. 7 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

EntityType $entity_type: 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 392
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;
  $entity_class = "ECKEntity";
  $controller_class = "EntityAPIController";
  $info[$entity_type->name] = array(
    'label' => t("@entity_type_label", array(
      "@entity_type_label" => $entity_type_label,
    )),
    'base table' => "eck_{$entity_type->name}",
    'entity class' => $entity_class,
    'controller class' => $controller_class,
    'access callback' => 'eck_entity_access',
    'form callback' => 'eck__entity__form',
    '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(
      'full' => array(
        'label' => t('Full'),
        'custom settings' => FALSE,
      ),
      'teaser' => array(
        'label' => t('Teaser'),
        'custom settings' => TRUE,
      ),
    ),
    // Inline entity form module integration.
    'inline entity form' => array(
      'controller' => 'EckInlineEntityFormController',
    ),
    'view callback' => 'eck__entity__view_callback',
  );
  $eck_path = eck__entity_type__path();
  foreach (Bundle::loadByEntityType($entity_type) as $bundle) {
    $bundle_label = $bundle->label;
    $path = "{$eck_path}/{$entity_type->name}/{$bundle->name}";
    $info[$entity_type->name]['bundles'][$bundle->name] = array(
      'label' => $bundle_label,
      'admin' => array(
        'path' => $path,
        'access callback' => 'eck_access',
        'access arguments' => array(
          'update',
          'bundle',
        ),
      ),
      'crud' => array(
        'add' => array(
          'path' => $path . "/add",
        ),
        'edit' => array(
          'path' => $path . "/%eckentity/edit",
          'entity_id' => 5,
        ),
        'delete' => array(
          'path' => $path . "/%eckentity/delete",
          'entity_id' => 5,
        ),
        'view' => array(
          'path' => "{$entity_type->name}/{$bundle->name}/%eckentity",
          'entity_id' => 2,
        ),
      ),
    );
  }
  return $info;
}