function DialogRenderer::determineTargetSelector

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::determineTargetSelector()
  2. 10 core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::determineTargetSelector()
  3. 11.x core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::determineTargetSelector()

Determine the target selector for the OpenDialogCommand.

Parameters

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

\Drupal\Core\Routing\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.

1 call to DialogRenderer::determineTargetSelector()
DialogRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php
Renders the main content render array into a response.

File

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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.