Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Quoting @webchick from #1734642-152: Move breakpoint module into core "I wonder if it's worth a wrapper function that can handle the "is it a module or is it a theme?" question and dispatch accordingly."
This so we can avoid doing things like:
function my_function ($theme_key or _module_name) {
$found = FALSE;
$themes = list_themes();
if (isset($themes[$theme_key or _module_name])) {
$found = 'theme';
}
elseif (module_exists($theme_key or _module_name)) {
$found = 'module';
}
else {
return FALSE;
}
// ....
switch ($found) {
case 'theme':
// use $themes[$theme_key]->info['name']
break;
case 'module':
// use the machine name
break;
}
}
Comments
Comment #1
Crell CreditAttribution: Crell commentedThis should be part of #1331486: Move module_invoke_*() and friends to an Extensions class. New metadata about an extension. We don't need another one-off function for it.
postponing on that issue, then we can add this as a utility method.
Comment #2
PanchoUn-postponing because #1331486: Move module_invoke_*() and friends to an Extensions class turned out to become a mere ModuleHandler, not an ExtensionHandler class.
We might want to revisit the one-off procedural approach for now, or postpone on another issue.
In any case the references need to be fixed pointing to this issue not another one, see: #2019907: Fix referring to the wrong issue in breakpoint.module.
Comment #3
dawehnerRelated to #2208429: Extension System, Part III: ExtensionList, ModuleExtensionList and ProfileExtensionList