Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ModalRenderer.php

class ModalRenderer

Default main content renderer for modal dialog requests.

Hierarchy

  • class \Drupal\Core\Render\MainContent\DialogRenderer implements \Drupal\Core\Render\MainContent\MainContentRendererInterface
    • class \Drupal\Core\Render\MainContent\ModalRenderer extends \Drupal\Core\Render\MainContent\DialogRenderer

Expanded class hierarchy of ModalRenderer

File

core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php, line 13

Namespace

Drupal\Core\Render\MainContent
View source
class ModalRenderer extends DialogRenderer {
    
    /**
     * {@inheritdoc}
     */
    public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
        $response = new AjaxResponse();
        // First render the main content, because it might provide a title.
        $content = $this->renderer
            ->renderRoot($main_content);
        // Attach the library necessary for using the OpenModalDialogCommand and set
        // the attachments for this Ajax response.
        $main_content['#attached']['library'][] = 'core/drupal.dialog.ajax';
        $response->setAttachments($main_content['#attached']);
        // Determine the title.
        $title = $this->getTitleAsStringable($main_content, $request, $route_match);
        // Determine the dialog options for the OpenDialogCommand.
        $options = $this->getDialogOptions($request);
        $response->addCommand(new OpenModalDialogCommand($title, $content, $options));
        return $response;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DialogRenderer::$renderer protected property The renderer. 1
DialogRenderer::$titleResolver protected property The title resolver.
DialogRenderer::determineTargetSelector protected function Determine the target selector for the OpenDialogCommand.
DialogRenderer::getDialogOptions protected function Returns the dialog options from request.
DialogRenderer::getTitleAsStringable protected function Gets the title as a string or stringable object.
DialogRenderer::__construct public function Constructs a new DialogRenderer. 1
ModalRenderer::renderResponse public function Renders the main content render array into a response. Overrides DialogRenderer::renderResponse

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal