You are here

function _bricks_theme_registry_serve_path in Bricks​ 7.5

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

1 call to _bricks_theme_registry_serve_path()
bricks_theme_registry_alter in ./bricks.module
Implements hook_theme_registry_alter().

File

./bricks.module, line 36

Code

function _bricks_theme_registry_serve_path(&$theme_registry, $theme, $path) {
  $theme_registry_copy = $theme_registry;
  _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', $theme, $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, $path);
      }
      else {
        array_unshift($theme_registry[$hook]['theme paths'], $path);
      }
    }
  }
}