From a2f089fcf7e08d6d2f91a297dfd48e441d8875e7 Mon Sep 17 00:00:00 2001 From: Steven McCoy Date: Sun, 14 Apr 2019 07:45:24 -0400 Subject: [PATCH] Ensures context attributes are an array Without this, we encounter numerous warnings about running foreach on a non-array --- bem.function.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bem.function.php b/bem.function.php index 00bd459..b86550e 100644 --- a/bem.function.php +++ b/bem.function.php @@ -43,6 +43,11 @@ if (class_exists('Drupal')) { $attributes = new Attribute(); + // Ensure that the context attributes are an array (this is not a given) + if (!$context['attributes']) { + $context['attributes'] = []; + } + // Iterate the attributes available in context. foreach($context['attributes'] as $key => $value) { // If there are classes, add them to the classes array.