When I add classes to preprocess menu, I have many notices like this
Notice: Array to string conversion in Drupal\bootstrap\Utility\Attributes->addClass() (line 29 of themes/bootstrap/src/Utility/Attributes.php).
and this
Notice: Array to string conversion in Drupal\Core\Template\AttributeArray->__toString() (line 73 of core/lib/Drupal/Core/Template/AttributeArray.php).
I use php 7.1.6 and Drupal 8.6.4, it started with version bootstrap 8.x-3.14
Code of preprocess function

/**
 * Implements hook_preprocess_menu().
 */
function MYMODULE_preprocess_menu(&$variables) {
  foreach ($variables['items'] as $key => $item) {
  	 $variables['items'][$key]['attributes']->addClass(array('class1', 'class2'));
  }
}
And this hook_preprocess_menu() do not add classes to menu. When I use Bartic theme - all OK.

Comments

s73 created an issue. See original summary.

s73’s picture

Assigned: s73 » Unassigned
Issue summary: View changes
markhalliwell’s picture

Category: Bug report » Support request
Status: Active » Closed (works as designed)
Related issues: +#2269653: [bootstrap][policy][7.x-3.x] CSS Classes (Fatal error: [] operator not supported for strings)