X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fsrc%2FPlugin%2FAlter%2FThemeSuggestions.php;fp=web%2Fthemes%2Fcontrib%2Fbootstrap%2Fsrc%2FPlugin%2FAlter%2FThemeSuggestions.php;h=bf20a2307cdc977abb13a21c0c7377612413de30;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=ce29ba64bf6c19620e02428b7ba37e07a4910c4a;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeSuggestions.php b/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeSuggestions.php index ce29ba64b..bf20a2307 100644 --- a/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeSuggestions.php +++ b/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeSuggestions.php @@ -1,12 +1,7 @@ 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; + } } } @@ -161,14 +161,14 @@ class ThemeSuggestions extends PluginBase implements AlterInterface { * This is a helper method because core's implementation of theme hook * suggestions on entities is inconsistent. * - * @see https://www.drupal.org/node/2808481 - * * @param string $entity_type * Optional. A specific type of entity to look for. * @param string $prefix * Optional. A prefix (like "entity") to use. It will automatically be * appended with the "__" separator. * + * @see https://www.drupal.org/node/2808481 + * * @todo Remove/refactor once core issue is resolved. */ protected function addSuggestionsForEntity($entity_type = 'entity', $prefix = '') { @@ -180,6 +180,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 +198,11 @@ class ThemeSuggestions extends PluginBase implements AlterInterface { $suggestions[] = $prefix . $entity_type_id . '__' . $entity->bundle() . '__' . $view_mode; } } + + // Add suggestions. + if ($suggestions) { + $this->addSuggestion($suggestions); + } } } @@ -206,6 +213,7 @@ class ThemeSuggestions extends PluginBase implements AlterInterface { * The theme hook suggestion to build. * * @return array + * An list of theme hook suggestions. */ protected function buildSuggestions($hook) { $suggestions = [];