Skip to content

Commit

Permalink
ELA-751: Add bundle to Listing pattern.
Browse files Browse the repository at this point in the history
  • Loading branch information
julien- committed Aug 9, 2023
1 parent 296d02e commit 7af0207
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions includes/listing.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* @file
* Theme and preprocess functions for Pattern listing.
*/

declare(strict_types = 1);

/**
* Implements hook_preprocess_HOOK().
*/
function oe_bootstrap_theme_preprocess_pattern_listing(array &$variables) {
if (!empty($variables['items'])) {
foreach ($variables['items'] as &$item) {
if (!empty($item['content']['#theme'])) {
$id = $item['content']['#theme'];
if (!empty($item['content']['#'. $id])) {
/** @var Drupal\Core\Entity\ $entity */
$entity = $item['content']['#'. $id];
$variables['attributes']->addClass($entity->bundle());
}
}
}
}
}

0 comments on commit 7af0207

Please sign in to comment.