function styles_get_registered_classes in Styles 6
Same name and namespace in other branches
- 6.2 styles.module \styles_get_registered_classes()
- 7.2 styles.module \styles_get_registered_classes()
Builds a registry of Style classes.
Each module supporting a Style will need to implement hook_styles_register, which will need to return an associated array keyed by the style class name, with an array containing the following key => value pairs: 'field_types' => An array of field types to apply this style to. The following key => value pairs are optional, which will otherwise be automatically derived: 'name' => The human-readable name of the style. 'description' => A description of the style. 'path' => The path where the class file resides. 'file' => The file containing the class definition. 'module' => The module defining the class. The following key => value pair will be automatically set to the association and cannot be overridden: 'class_name' => The actual name of the class.
Parameters
string $style: (Optional) The style of the specific class registration to return.
boolean $reset: (Optional) If TRUE, then reset the registration.
Return value
array If $style is specified, then return only the specified class definition, or NULL if there is no such registered class. Otherwise, return the entire class definition registry.
2 calls to styles_get_registered_classes()
- styles_get_styles_class_by_class_name in ./
styles.module - Return the registered Styles class definition specified by name.
- styles_init in ./
styles.module - Implementation of hook_init().
File
- ./
styles.module, line 238 - Bundles similar display formatters together.
Code
function styles_get_registered_classes($style = NULL, $reset = FALSE) {
$registered_classes =& _styles_drupal_static(__FUNCTION__);
if ($reset || !isset($registered_classes)) {
$registered_classes = array();
// Build our media object class registry.
foreach (module_implements('styles_register') as $module) {
foreach (module_invoke($module, 'styles_register') as $style => $class) {
$registered_classes[$style] = is_array($class) ? $class : array();
$registered_classes[$style]['class_name'] = $style;
if (!isset($registered_classes[$style]['name'])) {
$registered_classes[$style]['name'] = t($style);
}
if (!isset($registered_classes[$style]['description'])) {
$registered_classes[$style]['description'] = t('Class definition for @style.', array(
'@style' => $style,
));
}
if (!isset($registered_classes[$style]['path'])) {
$registered_classes[$style]['path'] = drupal_get_path('module', $module);
}
if (!isset($registered_classes[$style]['file'])) {
$registered_classes[$style]['file'] = $style . '.inc';
}
if (!isset($registered_classes[$style]['module'])) {
$registered_classes[$style]['module'] = $module;
}
}
}
}
if (isset($style)) {
return $registered_classes[$style];
}
return $registered_classes;
}