// the attachments for this Ajax response.
$main_content['#attached'
]['library'
][] = 'core/drupal.dialog.ajax';
$response->
setAttachments($main_content['#attached'
]);
// If the main content doesn't provide a title, use the title resolver.
$title =
$main_content['#title'
] ??
$this->titleResolver->
getTitle($request,
$route_match->
getRouteObject());
// Determine the title: use the title provided by the main content if any,
// otherwise get it from the routing information.
$options =
$request->request->
all('dialogOptions'
);
$response->
addCommand(new OpenModalDialogCommand($title,
$content,
$options));
return $response;
}}