summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Plugin/Alter/ThemeSuggestions.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/Plugin/Alter/ThemeSuggestions.php b/src/Plugin/Alter/ThemeSuggestions.php
index ce29ba6..b4a4c63 100644
--- a/src/Plugin/Alter/ThemeSuggestions.php
+++ b/src/Plugin/Alter/ThemeSuggestions.php
@@ -143,15 +143,18 @@ class ThemeSuggestions extends PluginBase implements AlterInterface {
***************************************************************************/
/**
- * Add a suggestion to the list of suggestions.
+ * Adds suggestions based on an array of hooks.
*
- * @param string $hook
- * The theme hook suggestion to add.
+ * @param string|string[] $hook
+ * A single theme hook suggestion or an array of theme hook suggestions.
*/
protected function addSuggestion($hook) {
- $suggestions = $this->buildSuggestions($hook);
- foreach ($suggestions as $suggestion) {
- $this->suggestions[] = $suggestion;
+ $hooks = (array) $hook;
+ foreach ($hooks as $hook) {
+ $suggestions = $this->buildSuggestions($hook);
+ foreach ($suggestions as $suggestion) {
+ $this->suggestions[] = $suggestion;
+ }
}
}
@@ -180,6 +183,8 @@ class ThemeSuggestions extends PluginBase implements AlterInterface {
// Extract the entity.
if ($entity = $this->getEntityObject($entity_type)) {
$entity_type_id = $entity->getEntityTypeId();
+ $suggestions = [];
+
// Only add the entity type identifier if there's a prefix.
if (!empty($prefix)) {
$prefix .= '__';
@@ -196,6 +201,11 @@ class ThemeSuggestions extends PluginBase implements AlterInterface {
$suggestions[] = $prefix . $entity_type_id . '__' . $entity->bundle() . '__' . $view_mode;
}
}
+
+ // Add suggestions.
+ if ($suggestions) {
+ $this->addSuggestion($suggestions);
+ }
}
}