function DialogRenderer::getTitleAsStringable

Same name in other branches
  1. 10 core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::getTitleAsStringable()

Gets the title as a string or stringable object.

Uses the title provided by the main content if any, otherwise gets it from the routing information.

Parameters

array $main_content: The main content array.

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

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

Return value

\Stringable|string|null The title as a string or stringable object.

4 calls to DialogRenderer::getTitleAsStringable()
DialogRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php
Renders the main content render array into a response.
ModalRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php
Renders the main content render array into a response.
OffCanvasRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php
Renders the main content render array into a response.
WideModalRenderer::renderResponse in core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php
Renders the main content render array into a response.

File

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

Class

DialogRenderer
Default main content renderer for dialog requests.

Namespace

Drupal\Core\Render\MainContent

Code

protected function getTitleAsStringable(array $main_content, Request $request, RouteMatchInterface $route_match) : \Stringable|string|null {
    $title = $main_content['#title'] ?? $this->titleResolver
        ->getTitle($request, $route_match->getRouteObject());
    if (is_array($title)) {
        $title = $this->renderer
            ->renderInIsolation($title);
    }
    return $title;
}

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