function quiz_entity_info in Quiz 7.5
Same name and namespace in other branches
- 7.6 quiz.module \quiz_entity_info()
Implements hook_entity_info().
File
- ./
quiz.module, line 3399 - quiz.module Main file for the Quiz module.
Code
function quiz_entity_info() {
$entity_info = array(
'quiz' => array(
'base table' => 'quiz_node_properties',
'controller class' => 'QuizController',
'entity class' => 'Quiz',
'entity keys' => array(
'id' => 'qnp_id',
),
'label' => 'Quiz properties',
'metadata controller class' => 'QuizMetadataController',
'views controller class' => 'EntityDefaultViewsController',
),
'quiz_question_relationship' => array(
'base table' => 'quiz_node_relationship',
'controller class' => 'QuizQuestionRelationshipController',
'entity class' => 'QuizQuestionRelationship',
'entity keys' => array(
'id' => 'qnr_id',
),
'label' => 'Quiz question relationship',
'metadata controller class' => 'QuizQuestionRelationshipMetadataController',
'views controller class' => 'EntityDefaultViewsController',
),
'quiz_result' => array(
'base table' => 'quiz_node_results',
'bundles' => array(),
'controller class' => 'QuizResultController',
'entity class' => 'QuizResult',
'entity keys' => array(
'id' => 'result_id',
'bundle' => 'type',
),
'bundle keys' => array(
'bundle' => 'type',
),
'fieldable' => TRUE,
'label' => 'Quiz result',
'label callback' => 'entity_class_label',
'metadata controller class' => 'QuizResultMetadataController',
'views controller class' => 'EntityDefaultViewsController',
'access callback' => 'quiz_result_access',
),
'quiz_result_answer' => array(
'base table' => 'quiz_node_results_answers',
'bundles' => array(
'quiz_result_answer' => array(
'label' => 'Quiz result answer',
'admin' => array(
'path' => 'admin/quiz/result_answer',
'access arguments' => array(
'administer quiz configuration',
),
),
),
),
'controller class' => 'QuizResultAnswerController',
'entity class' => 'QuizResultAnswer',
'entity keys' => array(
'id' => 'result_answer_id',
),
'fieldable' => TRUE,
'label' => 'Quiz result answer',
'metadata controller class' => 'QuizResultAnswerMetadataController',
'views controller class' => 'EntityDefaultViewsController',
),
);
if (db_table_exists('quiz_result_type')) {
$entity_info['quiz_result_type'] = array(
'label' => t('Quiz result type'),
'entity class' => 'Entity',
'plural label' => t('Quiz result types'),
'description' => t('Quiz result types.'),
'controller class' => 'EntityAPIControllerExportable',
'base table' => 'quiz_result_type',
'fieldable' => FALSE,
'bundle of' => 'quiz_result',
'exportable' => TRUE,
'entity keys' => array(
'id' => 'id',
'name' => 'type',
'label' => 'label',
),
'access callback' => 'quiz_result_type_access',
'module' => 'quiz',
// Enable the entity API's admin UI.
'admin ui' => array(
'path' => 'admin/quiz/result',
'controller class' => 'EntityDefaultUIController',
),
);
// Populate our bundles.
$types = db_select('quiz_result_type', 'qrt')
->fields('qrt')
->execute()
->fetchAllAssoc('type');
foreach ($types as $type => $info) {
$entity_info['quiz_result']['bundles'][$type] = array(
'label' => $info->label,
'admin' => array(
'path' => 'admin/quiz/result/manage/%quiz_result_type',
'real path' => 'admin/quiz/result/manage/' . $type,
'bundle argument' => 4,
'access arguments' => array(
'administer quiz result types',
),
),
);
}
}
return $entity_info;
}