function modernizr_api_list in Modernizr 8
Same name and namespace in other branches
- 7.3 modernizr.module \modernizr_api_list()
Asks other Drupal modules which Modernizr tests they need.
Return value
array
3 calls to modernizr_api_list()
- ModernizrUnitTestCase::testModernizrInfo in tests/
modernizr.test - Tests that modernizr's own implementation of hook_modernizr_info works.
- modernizr_generate_url in ./
modernizr.admin.inc - Generates new Modernizr URL for admin interface Callback for 'admin/config/development/modernizr'.
- _modernizr_drush_custom_build in drush/
modernizr.drush.inc - Helper function that generates a list of Modernizr tests from other modules and sends them to the node.js CLI builder.
1 string reference to 'modernizr_api_list'
- modernizr_generate_url in ./
modernizr.admin.inc - Generates new Modernizr URL for admin interface Callback for 'admin/config/development/modernizr'.
File
- ./
modernizr.module, line 537 - Main module file for Modernizr
Code
function modernizr_api_list() {
$tests =& drupal_static(__FUNCTION__);
if (!isset($tests)) {
// Grab all module implementations
// Note: this is a slightly augmented version of module_invoke_all(), so
// that we can know which module is providing which test.
$hook = 'modernizr_info';
foreach (module_implements($hook) as $module) {
$function = $module . '_' . $hook;
if (function_exists($function)) {
$result = call_user_func($function);
if (isset($result) && is_array($result)) {
$tests[$module] = $result;
}
}
}
// Grabbing the information with an hook_alter is not enough for themes
// because they will not all be active, nor their code added into the session.
$themes = list_themes();
$active_themes = array();
foreach ($themes as $theme_name => $theme) {
if ($theme->status == 1) {
$active_themes[$theme_name] = $theme;
if (isset($theme->base_themes)) {
foreach ($theme->base_themes as $base_theme_name => $base_theme) {
$active_themes[$base_theme_name] = $themes[$base_theme_name];
}
}
}
}
// We now go into every active theme and pull from the .info file the tests.
foreach ($active_themes as $active_theme) {
$data = drupal_parse_info_file($active_theme->filename);
if (isset($data['modernizr']) && isset($data['modernizr']['tests'])) {
// There are modernizr tests within this theme.
$theme_name = $data['name'];
$tests[$theme_name] = $data['modernizr']['tests'];
}
}
// The last thing we do is send it to have its data cleaned and organized.
$tests = _modernizr_api_list_clean($tests);
}
return $tests;
}