Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / menu_link_content / src / Controller / MenuController.php
1 <?php
2
3 namespace Drupal\menu_link_content\Controller;
4
5 use Drupal\Core\Controller\ControllerBase;
6 use Drupal\system\MenuInterface;
7
8 /**
9  * Defines a route controller for a form for menu link content entity creation.
10  */
11 class MenuController extends ControllerBase {
12
13   /**
14    * Provides the menu link creation form.
15    *
16    * @param \Drupal\system\MenuInterface $menu
17    *   An entity representing a custom menu.
18    *
19    * @return array
20    *   Returns the menu link creation form.
21    */
22   public function addLink(MenuInterface $menu) {
23     $menu_link = $this->entityManager()->getStorage('menu_link_content')->create([
24       'id' => '',
25       'parent' => '',
26       'menu_name' => $menu->id(),
27       'bundle' => 'menu_link_content',
28     ]);
29     return $this->entityFormBuilder()->getForm($menu_link);
30   }
31
32 }