determineTargetSelector example

// Attach the library necessary for using the OpenDialogCommand and set the     // attachments for this Ajax response.     $main_content['#attached']['library'][] = 'core/drupal.dialog.ajax';
    $response->setAttachments($main_content['#attached']);

    // Determine the title: use the title provided by the main content if any,     // otherwise get it from the routing information.     $title = $main_content['#title'] ?? $this->titleResolver->getTitle($request$route_match->getRouteObject());

    // Determine the dialog options and the target for the OpenDialogCommand.     $options = $request->request->all('dialogOptions');
    $target = $this->determineTargetSelector($options$route_match);

    $response->addCommand(new OpenDialogCommand($target$title$content$options));
    return $response;
  }

  /** * Determine the target selector for the OpenDialogCommand. * * @param array &$options * The 'target' option, if set, is used, and then removed from $options. * @param \Drupal\Core\Routing\RouteMatchInterface $route_match * When no 'target' option is set in $options, $route_match is used instead * to determine the target. * * @return string * The target selector. */
Home | Imprint | This part of the site doesn't use cookies.