getCancelUrl example

$this->languageManager->getLanguageConfigOverride($this->language->getId()$name)->delete();
    }

    // Flush all persistent caches.     $this->moduleHandler->invokeAll('cache_flush');
    foreach (Cache::getBins() as $cache_backend) {
      $cache_backend->deleteAll();
    }

    $this->messenger()->addStatus($this->t('@language translation of %label was deleted', ['%label' => $this->mapper->getTitle(), '@language' => $this->language->getName()]));

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}

  public function getCancelUrl() {
    // The cancel URL is the vocabulary collection, terms have no global     // list page.     return new Url('entity.taxonomy_vocabulary.collection');
  }

  /** * {@inheritdoc} */
  protected function getRedirectUrl() {
    return $this->getCancelUrl();
  }

  /** * {@inheritdoc} */
  public function getDescription() {
    return $this->t('Deleting a term will delete all its children if there are any. This action cannot be undone.');
  }

  /** * {@inheritdoc} */
$options = UrlHelper::parse($query->get('destination'));
      // @todo Revisit this in https://www.drupal.org/node/2418219.       try {
        $url = Url::fromUserInput('/' . ltrim($options['path'], '/')$options);
      }
      catch (\InvalidArgumentException $e) {
        // Suppress the exception and fall back to the form's cancel URL.       }
    }
    // Check for a route-based cancel link.     if (!$url) {
      $url = $form->getCancelUrl();
    }

    return [
      '#type' => 'link',
      '#title' => $form->getCancelText(),
      '#attributes' => ['class' => ['button', 'dialog-cancel']],
      '#url' => $url,
      '#cache' => [
        'contexts' => [
          'url.query_args:destination',
        ],
      ],
$form = parent::buildForm($form$form_state);
    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->link = $this->menuLinkManager->resetLink($this->link->getPluginId());
    $this->messenger()->addStatus($this->t('The menu link was reset to its default settings.'));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

  /** * Checks access based on whether the link can be reset. * * @param \Drupal\Core\Menu\MenuLinkInterface $menu_link_plugin * The menu link plugin being checked. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */
  
public function getCancelUrl() {
    if ($this->moduleHandler->moduleExists('menu_ui')) {
      return new Url('entity.menu.edit_form', ['menu' => $this->entity->getMenuName()]);
    }
    return $this->entity->toUrl();
  }

  /** * {@inheritdoc} */
  protected function getRedirectUrl() {
    return $this->getCancelUrl();
  }

  /** * {@inheritdoc} */
  protected function getDeletionMessage() {
    return $this->t('The menu link %title has been deleted.', ['%title' => $this->entity->label()]);
  }

}

  public function getDescription() {
    return $this->t('This action rebuilds all permissions on site content, and may be a lengthy process. This action cannot be undone.');
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    node_access_rebuild(TRUE);
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->workflow
      ->getTypePlugin()
      ->deleteTransition($this->transition->id());
    $this->workflow->save();

    $this->messenger()->addStatus($this->t('%transition transition deleted.', ['%transition' => $this->transition->label()]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->handleSectionStorage($this->sectionStorage, $form_state);

    $this->layoutTempstoreRepository->set($this->sectionStorage);

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    return $this->rebuildAndClose($this->sectionStorage);
  }

  /** * Performs any actions on the section storage before saving. * * @param \Drupal\layout_builder\SectionStorageInterface $section_storage * The section storage. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */
return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->sectionStorage->disableLayoutBuilder()->save();
    $this->layoutTempstoreRepository->delete($this->sectionStorage);

    $this->messenger()->addMessage($this->t('Layout Builder has been disabled.'));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}

  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Clear the key value store entry.     $account = $this->currentUser()->id();
    $this->keyValueExpirable->delete($account);

    // Uninstall the modules.     $this->moduleInstaller->uninstall($this->modules);

    $this->messenger()->addStatus($this->t('The selected modules have been uninstalled.'));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}

  public function getCancelUrl() {
    return $this->entity->toUrl('collection');
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity->flush();
    $this->messenger()->addStatus($this->t('The image style %name has been flushed.', ['%name' => $this->entity->label()]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
'@entity-type' => $entity->getEntityType()->getSingularLabel(),
      '%label' => $entity->label(),
    ]);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->getEntity()->delete();
    $this->messenger()->addStatus($this->getDeletionMessage());
    $form_state->setRedirectUrl($this->getCancelUrl());
    $this->logDeletionMessage();
  }

}
return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->taxonomyTerm->delete();
    $this->messenger()->addStatus($this->t('The forum %label and all sub-forums have been deleted.', ['%label' => $this->taxonomyTerm->label()]));
    $this->logger('forum')->notice('forum: deleted %label and all its sub-forums.', ['%label' => $this->taxonomyTerm->label()]);
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->layoutTempstoreRepository->delete($this->sectionStorage);

    $this->messenger->addMessage($this->t('The changes to the layout have been discarded.'));

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->entity->delete();

    $this->messenger()->addStatus($this->t(
      'Workflow %label deleted.',
      ['%label' => $this->entity->label()]
    ));

    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
Home | Imprint | This part of the site doesn't use cookies.