function course_get_handlers in Course 7
Same name and namespace in other branches
- 8.3 course.module \course_get_handlers()
- 8.2 course.module \course_get_handlers()
- 6 course.module \course_get_handlers()
- 7.2 course.module \course_get_handlers()
- 3.x course.module \course_get_handlers()
Get course handlers.
Parameters
string $type: (optional) The course handler type to return. If no type is specified, all types are returned.
Return value
array A merged, structured array of course handlers, optionally limited by type.
array An array of hook implementations keyed by module name, containing:
- A single handler type definition, if the $type parameter is passed.
- Or an associative array of all course handler definitions keyed by type.
13 calls to course_get_handlers()
- CourseObject::getComponentName in includes/
CourseObject.inc - Get the object component title for this course object.
- CourseObject::getTitle in includes/
CourseObject.inc - CourseObjectContentTestCase::testContentCourseObjectCreation in modules/
course_content/ course_content.test - Test course content object creation.
- CourseObjectController::create in includes/
CourseObjectController.inc - Overrides EntityAPIController::create().
- CourseObjectFulfillmentController::create in includes/
CourseObjectFulfillmentController.inc - Overrides EntityAPIController::create().
File
- ./
course.module, line 318 - course.module Core functionality for Courses.
Code
function course_get_handlers($type = NULL, $flush = FALSE) {
$all =& drupal_static(__FUNCTION__, array());
if (!$all || $flush) {
// Allow modules to define handlers that extend Course functionality.
// Do not use module_invoke_all() here because we need to know which module
// is providing the 'object' handler type. This is to avoid namespace
// conflicts between multiple modules providing a 'quiz' object for example.
$hook = 'course_handlers';
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
$handlers = $function();
// Allow modules to alter each other's list of handlers.
drupal_alter($hook, $handlers, $module);
if (isset($handlers) && is_array($handlers)) {
$all[$module] = $handlers;
}
}
}
if (isset($type)) {
// Loop through each module's result again, and rebuild the array including
// only the specified handler type. We do this again so we can static cache
// the hook invocation and function calls above.
$filtered = array();
foreach ($all as $module => $handlers) {
if (isset($handlers[$type])) {
$filtered[$module] = $handlers[$type];
}
}
// Return the keyed array of implementations, each filtered to include only
// the specified handler type definition.
return $filtered;
}
else {
// Return the keyed array of all implementations.
return $all;
}
}