protected function DialogRenderer::determineTargetSelector

protected DialogRenderer::determineTargetSelector(array &$options, RouteMatchInterface $route_match)

Determine the target selector for the OpenDialogCommand.

Parameters

array &$options: The 'target' option, if set, is used, and then removed from $options.

RouteMatchInterface $route_match: When no 'target' option is set in $options, $route_match is used instead to determine the target.

Return value

string The target selector.

File

core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php, line 72

Class

DialogRenderer
Default main content renderer for dialog requests.

Namespace

Drupal\Core\Render\MainContent

Code

protected function determineTargetSelector(array &$options, RouteMatchInterface $route_match) {
  // Generate the target wrapper for the dialog.
  if (isset($options['target'])) {
    // If the target was nominated in the incoming options, use that.
    $target = $options['target'];
    // Ensure the target includes the #.
    if (substr($target, 0, 1) != '#') {
      $target = '#' . $target;
    }
    // This shouldn't be passed on to jQuery.ui.dialog.
    unset($options['target']);
  }
  else {
    // Generate a target based on the route id.
    $route_name = $route_match->getRouteName();
    $target = '#' . Html::getUniqueId("drupal-dialog-$route_name");
  }
  return $target;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!MainContent!DialogRenderer.php/function/DialogRenderer::determineTargetSelector/8.1.x