class MenuLinkDeleteForm

Defines a confirmation form for deletion of a single menu link.

Hierarchy

Expanded class hierarchy of MenuLinkDeleteForm

1 string reference to 'MenuLinkDeleteForm'
menu.routing.yml in drupal/core/modules/menu/menu.routing.yml
drupal/core/modules/menu/menu.routing.yml

File

drupal/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php, line 16
Contains \Drupal\menu\Form\MenuLinkDeleteForm.

Namespace

Drupal\menu\Form
View source
class MenuLinkDeleteForm extends ConfirmFormBase {

  /**
   * The menu link object to be deleted.
   *
   * @var \Drupal\menu_link\Plugin\Core\Entity\MenuLink
   */
  protected $menuLink;

  /**
   * {@inheritdoc}
   */
  protected function getQuestion() {
    return t('Are you sure you want to delete the custom menu link %item?', array(
      '%item' => $this->menuLink->link_title,
    ));
  }

  /**
   * {@inheritdoc}
   */
  protected function getCancelPath() {
    return 'admin/structure/menu/manage/' . $this->menuLink->menu_name;
  }

  /**
   * {@inheritdoc}
   */
  public function getFormID() {
    return 'menu_link_delete_form';
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, array &$form_state, MenuLink $menu_link = NULL) {
    $this->menuLink = $menu_link;
    return parent::buildForm($form, $form_state);
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, array &$form_state) {
    menu_link_delete($this->menuLink
      ->id());
    $t_args = array(
      '%title' => $this->menuLink->link_title,
    );
    drupal_set_message(t('The menu link %title has been deleted.', $t_args));
    watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE);
    $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->menuLink->menu_name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfirmFormBase::getCancelText protected function Returns a caption for the link which cancels the action. 2
ConfirmFormBase::getConfirmText protected function Returns a caption for the button that confirms the action. 27
ConfirmFormBase::getDescription protected function Returns additional text to display as a description. 10
ConfirmFormBase::getFormName protected function Returns the internal name used to refer to the confirmation item.
ConfirmFormBase::validateForm public function Implements \Drupal\Core\Form\FormInterface::validateForm(). Overrides FormInterface::validateForm 1
MenuLinkDeleteForm::$menuLink protected property The menu link object to be deleted.
MenuLinkDeleteForm::buildForm public function Implements \Drupal\Core\Form\FormInterface::buildForm(). Overrides ConfirmFormBase::buildForm
MenuLinkDeleteForm::getCancelPath protected function Returns the page to go to if the user cancels the action. Overrides ConfirmFormBase::getCancelPath
MenuLinkDeleteForm::getFormID public function Returns a unique string identifying the form. Overrides FormInterface::getFormID
MenuLinkDeleteForm::getQuestion protected function Returns the question to ask the user. Overrides ConfirmFormBase::getQuestion
MenuLinkDeleteForm::submitForm public function Form submission handler. Overrides FormInterface::submitForm