You are here

public function WebformNodeEntityReferenceController::change in Webform 6.x

Same name and namespace in other branches
  1. 8.5 modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php \Drupal\webform_node\Controller\WebformNodeEntityReferenceController::change()

Set the current webform for a node with multiple webform attached.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request.

\Drupal\node\NodeInterface $node: A node.

\Drupal\webform\WebformInterface $webform: A webform.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect to a selected destination or the node's URL.

1 string reference to 'WebformNodeEntityReferenceController::change'
webform_node.routing.yml in modules/webform_node/webform_node.routing.yml
modules/webform_node/webform_node.routing.yml

File

modules/webform_node/src/Controller/WebformNodeEntityReferenceController.php, line 47

Class

WebformNodeEntityReferenceController
Defines a controller for webform node entity references.

Namespace

Drupal\webform_node\Controller

Code

public function change(Request $request, NodeInterface $node, WebformInterface $webform) {
  $this->webformEntityReferenceManager
    ->setUserWebformId($node, $webform
    ->id());
  return new RedirectResponse($request->query
    ->get('destination') ?: $node
    ->toUrl()
    ->setAbsolute()
    ->toString());
}