Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

MenuController.php

Same filename in this branch
  1. 11.1.x core/modules/menu_ui/src/Controller/MenuController.php

Namespace

Drupal\menu_link_content\Controller

File

core/modules/menu_link_content/src/Controller/MenuController.php

View source
<?php

namespace Drupal\menu_link_content\Controller;

use Drupal\Core\Controller\ControllerBase;
use Drupal\system\MenuInterface;

/**
 * Defines a route controller for a form for menu link content entity creation.
 */
class MenuController extends ControllerBase {
    
    /**
     * Provides the menu link creation form.
     *
     * @param \Drupal\system\MenuInterface $menu
     *   An entity representing a custom menu.
     *
     * @return array
     *   Returns the menu link creation form.
     */
    public function addLink(MenuInterface $menu) {
        $menu_link = $this->entityTypeManager()
            ->getStorage('menu_link_content')
            ->create([
            'menu_name' => $menu->id(),
        ]);
        return $this->entityFormBuilder()
            ->getForm($menu_link);
    }

}

Classes

Title Deprecated Summary
MenuController Defines a route controller for a form for menu link content entity creation.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal