MenuController.php in Config menu link 8
File
src/Controller/MenuController.php
View source
<?php
namespace Drupal\menu_link_config\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\system\MenuInterface;
class MenuController extends ControllerBase {
public function addLink(MenuInterface $menu) {
$menu_link = $this
->entityTypeManager()
->getStorage('menu_link_config')
->create([
'id' => '',
'parent' => '',
'menu_name' => $menu
->id(),
'bundle' => 'menu_link_config',
]);
return $this
->entityFormBuilder()
->getForm($menu_link);
}
public static function getMenuLink($id) {
return (bool) \Drupal::entityTypeManager()
->getStorage('menu_link_config')
->load($id);
}
}