You are here

function bricks_theme_registry_alter in Bricks​ 7.4

Same name and namespace in other branches
  1. 7.5 bricks.module \bricks_theme_registry_alter()

Implements hook_theme_registry_alter() as described here: https://www.drupal.org/node/715160.

File

./bricks.module, line 33

Code

function bricks_theme_registry_alter(&$theme_registry, $module = 'bricks') {
  $theme_registry_copy = $theme_registry;
  $module_path = drupal_get_path('module', $module);
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', $module, $module_path);
  $theme_registry += array_diff_key($theme_registry_copy, $theme_registry);

  // A list of templates the module will provide templates for
  $hooks = array(
    'entity',
  );
  foreach ($hooks as $hook) {

    // Add the key 'theme paths' if it doesn't exist in this theme's registry
    if (!isset($theme_registry[$hook]['theme paths'])) {
      $theme_registry[$hook]['theme paths'] = array();
    }

    // Shift this module's directory to the top of the theme path list
    if (is_array($theme_registry[$hook]['theme paths'])) {
      $first_element = array_shift($theme_registry[$hook]['theme paths']);
      if ($first_element) {
        array_unshift($theme_registry[$hook]['theme paths'], $first_element, $module_path);
      }
      else {
        array_unshift($theme_registry[$hook]['theme paths'], $module_path);
      }
    }
  }
}