Unverified Commit c9203d89 authored by imclean's avatar imclean Committed by markcarver

Issue #3045621 by imclean, jungle: Menu items encounter NULL attributes

parent cf948b75
......@@ -20,7 +20,17 @@ class Menu extends PreprocessBase implements PreprocessInterface {
* {@inheritdoc}
*/
protected function preprocessVariables(Variables $variables) {
foreach ($variables->items as &$item) {
$this->convertAttributes($variables->items);
}
/**
* Converts attributes to core's Attribute class.
*
* @param array $items
* The menu items.
*/
protected function convertAttributes(array &$items) {
foreach ($items as &$item) {
$wrapperAttributes = new Attributes();
$linkAttributes = new Attributes();
if ($item['attributes'] instanceof Attribute || $item['attributes'] instanceof Attributes) {
......@@ -37,6 +47,9 @@ class Menu extends PreprocessBase implements PreprocessInterface {
// around this, just rewrap attributes in core's native Attribute class.
$item['attributes'] = new Attribute($wrapperAttributes->getArrayCopy());
$item['link_attributes'] = new Attribute($linkAttributes->getArrayCopy());
if ($item['below']) {
$this->convertAttributes($item['below']);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment