MiconStaticMenuLinkOverrides.php in Micon 8
File
micon_menu/src/MiconStaticMenuLinkOverrides.php
View source
<?php
namespace Drupal\micon_menu;
use Drupal\Core\Menu\StaticMenuLinkOverrides;
class MiconStaticMenuLinkOverrides extends StaticMenuLinkOverrides {
public function saveOverride($id, array $definition) {
$expected = [
'menu_name' => '',
'parent' => '',
'weight' => 0,
'expanded' => FALSE,
'enabled' => FALSE,
'options' => [],
];
$definition = array_intersect_key($definition, $expected);
$definition = $definition + $expected;
if ($definition) {
$definition['menu_name'] = (string) $definition['menu_name'];
$definition['parent'] = (string) $definition['parent'];
$definition['weight'] = (int) $definition['weight'];
$definition['expanded'] = (bool) $definition['expanded'];
$definition['enabled'] = (bool) $definition['enabled'];
$definition['options'] = $definition['options'];
$id = static::encodeId($id);
$all_overrides = $this
->getConfig()
->get('definitions');
$all_overrides[$id] = $definition + $this
->loadOverride($id);
$this
->getConfig()
->set('definitions', $all_overrides)
->save(TRUE);
}
return array_keys($definition);
}
}