You are here

public function EntityconnectController::returnTo in Entity connect 8.2

We redirect to the form page with the build_cache_id as a get param.

Parameters

string $cache_id: Build cache id.

bool $cancel: Whether or not the request was cancelled.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse The url of the parent page.

1 string reference to 'EntityconnectController::returnTo'
entityconnect.routing.yml in ./entityconnect.routing.yml
entityconnect.routing.yml

File

src/Controller/EntityconnectController.php, line 82

Class

EntityconnectController
Returns responses for Entityconnect module routes.

Namespace

Drupal\entityconnect\Controller

Code

public function returnTo($cache_id, $cancel = FALSE) {
  $cache_data = $this->entityconnectCache
    ->get($cache_id);
  $cache_data['cancel'] = $cancel;
  $this->entityconnectCache
    ->set($cache_id, $cache_data);
  $css_id = 'edit-' . str_replace('_', '-', $cache_data['field']) . '-wrapper';
  $options = [
    'query' => [
      'build_cache_id' => $cache_id,
      'return' => TRUE,
    ],
    'fragment' => $css_id,
  ];

  // Collect additional request parameters, skip 'q', since this is
  // the destination.
  foreach ($cache_data['params'] as $key => $value) {
    if ('build_cache_id' == $key) {
      continue;
    }
    $options['query'][$key] = $value;
  }
  $options['absolute'] = TRUE;
  $url = Url::fromRoute($cache_data['dest_route_name'], $cache_data['dest_route_params'], $options);
  return new RedirectResponse($url
    ->toString());
}