getRedirectDestination example

/** * Ensures that a destination is present on the given URL. * * @param \Drupal\Core\Url $url * The URL object to which the destination should be added. * * @return \Drupal\Core\Url * The updated URL object. */
  protected function ensureDestination(Url $url) {
    return $url->mergeOptions(['query' => $this->getRedirectDestination()->getAsArray()]);
  }

}
    // @see config_test.dynamic.dotted.default.yml     $list = $controller->load();
    $this->assertCount(1, $list, '1 ConfigTest entity found.');
    $entity = $list['dotted.default'];
    $this->assertInstanceOf(ConfigTest::class$entity);

    // Test getOperations() method.     $expected_operations = [
      'edit' => [
        'title' => 'Edit',
        'weight' => 10,
        'url' => $entity->toUrl()->setOption('query', $this->getRedirectDestination()->getAsArray()),
      ],
      'disable' => [
        'title' => 'Disable',
        'weight' => 40,
        'url' => $entity->toUrl('disable')->setOption('query', $this->getRedirectDestination()->getAsArray()),
      ],
      'delete' => [
        'title' => 'Delete',
        'weight' => 100,
        'attributes' => [
          'class' => ['use-ajax'],
          

  protected function getDestinationArray() {
    return $this->getRedirectDestination()->getAsArray();
  }

  /** * Returns the redirect destination service. * * @return \Drupal\Core\Routing\RedirectDestinationInterface * The redirect destination helper. */
  protected function getRedirectDestination() {
    if (!isset($this->redirectDestination)) {
      $this->redirectDestination = \Drupal::destination();
    }
/** * Gets the form's redirect URL from 'destination' provide in the request. * * @return \Drupal\Core\Url|null * The redirect URL or NULL if dialog should just be closed. */
  protected function getRedirectUrl() {
    // \Drupal\Core\Routing\RedirectDestination::get() cannot be used directly     // because it will use <current> if 'destination' is not in the query     // string.     if ($this->getRequest()->query->has('destination') && $destination = $this->getRedirectDestination()->get()) {
      return Url::fromUserInput('/' . $destination);
    }
  }

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