function ShortcutController::addForm

Same name and namespace in other branches
  1. 9 core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::addForm()
  2. 8.9.x core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::addForm()
  3. 10 core/modules/shortcut/src/Controller/ShortcutController.php \Drupal\shortcut\Controller\ShortcutController::addForm()

Returns a form to add a new shortcut to a given set.

Parameters

\Drupal\shortcut\ShortcutSetInterface $shortcut_set: The shortcut set this shortcut will be added to.

Return value

array The shortcut add form.

1 string reference to 'ShortcutController::addForm'
shortcut.routing.yml in core/modules/shortcut/shortcut.routing.yml
core/modules/shortcut/shortcut.routing.yml

File

core/modules/shortcut/src/Controller/ShortcutController.php, line 23

Class

ShortcutController
Provides route responses for <a href="/api/drupal/core%21modules%21taxonomy%21taxonomy.module/11.x" title="Enables the organization of content into categories." class="local">taxonomy.module</a>.

Namespace

Drupal\shortcut\Controller

Code

public function addForm(ShortcutSetInterface $shortcut_set) {
    $shortcut = $this->entityTypeManager()
        ->getStorage('shortcut')
        ->create([
        'shortcut_set' => $shortcut_set->id(),
    ]);
    return $this->entityFormBuilder()
        ->getForm($shortcut, 'add');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.