summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjacintocapote2017-04-20 15:14:06 -0500
committerMark Carver2017-04-20 15:14:06 -0500
commitff2d0bb65398b1a38b3d2ba22b6f8789c3831643 (patch)
treebdfa8347871eee06b642f39101b3b2a6a97b5a3b
parentabda003afd4dd3688d7c0e3cf2a3948729f76991 (diff)
Issue #2871551 by fastangel, markcarver: Problem to find template fileHEAD8.x-3.x
-rw-r--r--src/Plugin/Alter/ThemeRegistry.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Plugin/Alter/ThemeRegistry.php b/src/Plugin/Alter/ThemeRegistry.php
index 86ae770..7ff3ac7 100644
--- a/src/Plugin/Alter/ThemeRegistry.php
+++ b/src/Plugin/Alter/ThemeRegistry.php
@@ -87,12 +87,23 @@ class ThemeRegistry extends Registry implements AlterInterface {
$hook = str_replace('-', '_', str_replace('.html.twig', '', $file->filename));
$path = dirname($file->uri);
$incomplete = !isset($cache[$hook]) || strrpos($hook, '__');
+
+ // Create a new theme hook. This primarily happens when theme hook
+ // suggestion templates are created. To prevent the new hook from
+ // inheriting parent hook's "template", it must be manually set here.
+ // @see https://www.drupal.org/node/2871551
if (!isset($cache[$hook])) {
- $cache[$hook] = [];
+ $cache[$hook] = [
+ 'template' => str_replace('.html.twig', '', $file->filename),
+ ];
}
+
+ // Always ensure that "path", "type" and "theme path" are properly set.
$cache[$hook]['path'] = $path;
$cache[$hook]['type'] = $current_theme ? 'theme' : 'base_theme';
$cache[$hook]['theme path'] = $theme_path;
+
+ // Flag incomplete.
if ($incomplete) {
$cache[$hook]['incomplete preprocess functions'] = TRUE;
}