Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291053

String-parsing in hook_custom_theme() should be replaced with theme callbacks (for now)

$
0
0

There are several places in Drupal 8 that currently have code like the following:

<?php
/**
* Implements hook_custom_theme().
*
* @todo Add an event subscriber to the Ajax system to automatically set the
*   base page theme for all Ajax requests, and then remove this one off.
*/
function edit_custom_theme() {
  if (
substr(current_path(), 0, 5) === 'edit/') {
    return
ajax_base_page_theme();
  }
}
?>

That's incorrect, since theme callback functions should be used instead. In addition to being ugly, the code is also error-prone since other hook_custom_theme() implementations might accidentally override it, plus the string-matching might accidentally match paths it doesn't intend to.

There's an issue at #1954892: Figure out how to deal with 'theme callback' that may wind up doing something to replace theme callbacks in Drupal 8 anyway. However, it's an easy patch to fix it here first, and that way the other issue can just do more of a find/replace on "theme callback" rather than dealing with these too, which if nothing else will make an eventual patch there easier to review.


Viewing all articles
Browse latest Browse all 291053

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>