public static function CheeseburgerMenu::createFromSettings in Cheeseburger Menu 5.0.x
Creates menu from settings.
Parameters
array $settings: Settings to create menu from.
\Drupal\Core\Entity\EntityInterface $entity: Entity as source, menu and taxonomy vocabulary are supported.
Return value
static A new cheeseburger menu object.
2 calls to CheeseburgerMenu::createFromSettings()
- CheeseburgerMenuService::buildMenu in src/
CheeseburgerMenuService.php - Returns cheeseburger menu from menu.
- CheeseburgerMenuService::buildMenuFromVocabulary in src/
CheeseburgerMenuService.php - Returns cheeseburger menu from taxonomy vocabulary.
File
- src/
CheeseburgerMenu.php, line 126
Class
- CheeseburgerMenu
- Cheeseburger menu class.
Namespace
Drupal\cheeseburger_menuCode
public static function createFromSettings(array $settings, EntityInterface $entity) {
$instance = new static();
if ($settings['settings']['override_title']) {
$instance
->setTitle($settings['settings']['title_override']);
}
else {
$instance
->setTitle($entity
->label());
}
if (!$settings['settings']['show_title_in_navigation']) {
$instance
->hideNavigationTitle();
}
if (!$settings['settings']['show_title_above_menu']) {
$instance
->hideTitle();
}
if ($settings['settings']['collapsible_title'] ?? FALSE) {
$instance->wrapperAttribute
->addClass('cheeseburger-menu__title--collapsible');
if ($settings['settings']['title_default_expanded'] ?? TRUE) {
$instance->wrapperAttribute
->addClass('cheeseburger-menu__title--expanded');
}
}
$instance
->setIcon($settings['settings']['icon'])
->setOriginalEntityId($entity
->id())
->setOriginalEntityTypeId($entity
->getEntityTypeId())
->setWeight($settings['weight']);
$instance->id = Html::cleanCssIdentifier($entity
->getEntityTypeId() . '-' . $entity
->id());
return $instance;
}