You are here

function organigrams_entity_info in Organigrams 7

Implements hook_entity_info().

File

./organigrams.module, line 10
Defines the organigrams functions and entity types.

Code

function organigrams_entity_info() {
  $entities = array();

  // Declare the 'organigrams_item' entity.
  $entities['organigrams_item'] = array(
    'label' => t('Organigram item'),
    'controller class' => 'OrganigramsItemController',
    'base table' => 'organigrams_item_data',
    'fieldable' => FALSE,
    'entity keys' => array(
      'id' => 'iid',
      'bundle' => 'organigrams_machine_name',
      'label' => 'name',
    ),
    'bundle keys' => array(
      'bundle' => 'machine_name',
    ),
    'bundles' => array(),
    'module' => 'organigrams',
  );

  // Add all organigrams names as bundle to the organigrams item.
  foreach (organigrams_get_names() as $machine_name => $organigrams) {
    $entities['organigrams_item']['bundles'][$machine_name] = array(
      'label' => $organigrams->name,
      'admin' => array(
        'path' => 'admin/structure/organigrams/%organigrams_machine_name',
        'real path' => "admin/structure/organigrams/{$machine_name}",
        'bundle argument' => 3,
        'access callback' => 'organigrams_user_access',
        'access arguments' => array(
          'edit',
          3,
        ),
      ),
    );
  }

  // Declare the 'organigrams' entity.
  $entities['organigrams'] = array(
    'label' => t('Organigram'),
    'controller class' => 'OrganigramsController',
    'base table' => 'organigrams_data',
    'entity keys' => array(
      'id' => 'oid',
      'label' => 'name',
    ),
    'fieldable' => TRUE,
    'bundles' => array(
      'organigrams' => array(
        'label' => t('Organigram'),
        'admin' => array(
          'path' => 'admin/structure/organigrams',
        ),
      ),
    ),
    'view modes' => array(
      'organigram' => array(
        'label' => t('Organigram'),
        'custom settings' => TRUE,
      ),
      'organigram_block' => array(
        'label' => t('Organigram block'),
        'custom settings' => TRUE,
      ),
    ),
    'access callback' => 'organigrams_entity_access',
    'module' => 'organigrams',
  );
  return $entities;
}