Skip to content

Commit

Permalink
Issue nuvoleweb#298: Incorrect "path" in hook_theme definitions when …
Browse files Browse the repository at this point in the history
…the theme that contains patterns is not active.
  • Loading branch information
vever001 committed Jul 30, 2020
1 parent 4aa5e79 commit 00712d6
Showing 1 changed file with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,37 @@ public function getThemeImplementation() {
* Processed hook definition portion.
*/
protected function processCustomThemeHookProperty(PatternDefinition $definition) {
/** @var \Drupal\Core\Extension\Extension $module */
$return = [];
if (!$definition->hasCustomThemeHook() && $this->moduleHandler->moduleExists($definition->getProvider())) {
$module = $this->moduleHandler->getModule($definition->getProvider());
$return['path'] = $module->getPath() . '/templates';
if (!$definition->hasCustomThemeHook()) {
if ($this->templateExists($definition->getBasePath(), $definition->getTemplate())) {
$return['path'] = str_replace($this->root, '', $definition->getBasePath());
return ['path' => str_replace($this->root, '', $definition->getBasePath())];
}

$provider = $definition->getProvider();
$extension = $this->getProviderExtension($provider);
if ($extension) {
return ['path' => $extension->getPath() . '/templates'];
}
}
return $return;
return [];
}

/**
* Get the extension (module or theme) for the given provider.
*
* @param string $provider
* The name of the provider.
*
* @return \Drupal\Core\Extension\Extension|null
* The extension or NULL if none found.
*/
protected function getProviderExtension($provider) {
if ($this->moduleHandler->moduleExists($provider)) {
return $this->moduleHandler->getModule($provider);
}
elseif ($this->themeHandler->themeExists($provider)) {
return $this->themeHandler->getTheme($provider);
}
return NULL;
}

/**
Expand Down

0 comments on commit 00712d6

Please sign in to comment.