You are here

function course_entity_info in Course 7.2

Same name and namespace in other branches
  1. 7 course.module \course_entity_info()

Implements hook_entity_info().

File

./course.module, line 2724
course.module Core functionality for Courses.

Code

function course_entity_info() {
  $entity_info = array(
    'course_enrollment' => array(
      'label' => t('Course enrollment'),
      'entity class' => 'CourseEnrollment',
      'controller class' => 'EntityAPIController',
      'base table' => 'course_enrollment',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'eid',
        'bundle' => 'type',
      ),
      'label callback' => 'entity_class_label',
      'views controller class' => 'EntityDefaultViewsController',
      'bundles' => array(),
      'bundle keys' => array(
        'bundle' => 'type',
      ),
      'access callback' => 'course_enrollment_access',
    ),
    'course_enrollment_type' => array(
      'label' => t('Enrollment type'),
      'entity class' => 'Entity',
      'plural label' => t('Enrollment types'),
      'description' => t('Course enrollment types.'),
      'controller class' => 'EntityAPIControllerExportable',
      'base table' => 'course_enrollment_type',
      'fieldable' => FALSE,
      'entity class' => 'Entity',
      'bundle of' => 'course_enrollment',
      'exportable' => TRUE,
      'entity keys' => array(
        'id' => 'id',
        'name' => 'type',
        'label' => 'label',
      ),
      'access callback' => 'course_enrollment_type_access',
      'module' => 'course',
      // Enable the entity API's admin UI.
      'admin ui' => array(
        'path' => 'admin/course/enrollment-types',
        'controller class' => 'EntityDefaultUIController',
      ),
    ),
    'course_report' => array(
      'label' => t('Course report'),
      'entity class' => 'CourseReport',
      'controller class' => 'EntityAPIController',
      'base table' => 'course_report',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'crid',
      ),
      'label callback' => 'entity_class_label',
      'views controller class' => 'EntityDefaultViewsController',
      'bundles' => array(
        'course_report' => array(
          'label' => 'Course report',
          'admin' => array(
            'path' => 'admin/course/report',
            'access arguments' => array(
              'administer course',
            ),
          ),
        ),
      ),
      'access callback' => 'course_report_access',
    ),
    'course_object' => array(
      'label' => t('Course object'),
      'entity class' => 'CourseObject',
      'controller class' => 'CourseObjectController',
      'base table' => 'course_outline',
      'fieldable' => TRUE,
      'entity keys' => array(
        'id' => 'coid',
        'uuid' => 'uuid',
      ),
      'label callback' => 'course_object_label',
      'views controller class' => 'EntityDefaultViewsController',
      'bundles' => array(
        'course_object' => array(
          'label' => 'Course objects',
          'admin' => array(
            'path' => 'admin/course/object',
            'access arguments' => array(
              'administer course',
            ),
          ),
        ),
      ),
      'access callback' => 'course_access',
      'uuid' => TRUE,
    ),
    'course_object_fulfillment' => array(
      'label' => t('Course object fulfillment'),
      'entity class' => 'CourseObjectFulfillment',
      'controller class' => 'CourseObjectFulfillmentController',
      'base table' => 'course_outline_fulfillment',
      'fieldable' => FALSE,
      'entity keys' => array(
        'id' => 'cofid',
        'uuid' => 'uuid',
      ),
      'label callback' => 'course_object_fulfillment_label',
      'views controller class' => 'EntityDefaultViewsController',
      'access callback' => 'course_access',
      'uuid' => TRUE,
    ),
    'course' => array(
      'label' => t('Course'),
      'entity class' => 'Course',
      'controller class' => 'CourseController',
      'base table' => 'course_node',
      'fieldable' => FALSE,
      'entity keys' => array(
        'id' => 'nid',
      ),
      'label callback' => 'course_label',
      'views controller class' => 'EntityDefaultViewsController',
      'access callback' => 'course_access',
    ),
  );
  if (db_table_exists('course_enrollment_type')) {

    // Populate our bundles.
    $types = db_select('course_enrollment_type', 'cet')
      ->fields('cet')
      ->execute()
      ->fetchAllAssoc('type');
    foreach ($types as $type => $info) {
      $entity_info['course_enrollment']['bundles'][$type] = array(
        'label' => $info->label,
        'admin' => array(
          'path' => 'admin/course/enrollment-types/manage/%course_enrollment_type',
          'real path' => 'admin/course/enrollment-types/manage/' . $type,
          'bundle argument' => 4,
          'access arguments' => array(
            'administer course enrollment types',
          ),
        ),
      );
    }
  }
  return $entity_info;
}