You are here

function certificate_entity_info in Certificate 8.3

Same name and namespace in other branches
  1. 7.3 certificate.module \certificate_entity_info()

Certificate Entity Support

File

./certificate.module, line 796
Certificate module.

Code

function certificate_entity_info() {
  $entities = array();
  if (db_table_exists('certificate')) {
    $entities['certificate'] = array(
      'label' => 'Certificate',
      'base table' => 'certificate',
      'revision table' => 'certificate_revision',
      'entity class' => 'Entity',
      'controller class' => 'EntityAPIControllerExportable',
      'fieldable' => TRUE,
      'exportable' => TRUE,
      'label callback' => 'certificate_entity_info_label',
      'bundles' => array(),
      'bundle keys' => array(
        'bundle' => 'type',
      ),
      'entity keys' => array(
        'id' => 'cid',
        'bundle' => 'type',
        'revision' => 'vid',
        'label' => 'title',
        'name' => 'name',
      ),
      'module' => 'certificate',
      'access callback' => 'certificate_access',
      'views controller class' => 'EntityDefaultViewsController',
      'admin ui' => array(
        'file' => 'certificate.module',
        'path' => 'admin/structure/certificates',
        'controller class' => 'CertificateEntityUIController',
      ),
    );
  }
  if (db_table_exists('certificate_type')) {
    $entities['certificate_type'] = array(
      'label' => t('Certificate type'),
      'entity class' => 'Entity',
      'plural label' => t('Certificate types'),
      'description' => t('Certificate types.'),
      'controller class' => 'EntityAPIControllerExportable',
      'base table' => 'certificate_type',
      'fieldable' => FALSE,
      'entity class' => 'Entity',
      'bundle of' => 'certificate',
      'exportable' => TRUE,
      'entity keys' => array(
        'id' => 'id',
        'name' => 'type',
        'label' => 'label',
      ),
      'access callback' => 'certificate_type_access',
      'module' => 'course',
      // Enable the entity API's admin UI.
      'admin ui' => array(
        'file' => 'certificate.module',
        'path' => 'admin/structure/certificate-types',
        'controller class' => 'EntityDefaultUIController',
      ),
    );

    // Populate our bundles.
    $types = db_select('certificate_type', 'ct')
      ->fields('ct')
      ->execute()
      ->fetchAllAssoc('type');
    foreach ($types as $type => $info) {
      $entities['certificate']['bundles'][$type] = array(
        'label' => $info->label,
        'admin' => array(
          'path' => 'admin/structure/certificate-types/manage/%certificate_type',
          'real path' => 'admin/structure/certificate-types/manage/' . $type,
          'bundle argument' => 4,
          'access arguments' => array(
            'administer certificate',
          ),
        ),
      );
    }
  }
  return $entities;
}