OpenOffCanvasDialogCommand example


class OpenOffCanvasDialogCommandTest extends UnitTestCase {

  /** * @covers ::render * * @dataProvider dialogPosition */
  public function testRender($position) {
    $command = new OpenOffCanvasDialogCommand('Title', '<p>Text!</p>', ['url' => 'example'], NULL, $position);

    $expected = [
      'command' => 'openDialog',
      'selector' => '#drupal-off-canvas',
      'settings' => NULL,
      'data' => '<p>Text!</p>',
      'dialogOptions' => [
        'url' => 'example',
        'title' => 'Title',
        'modal' => FALSE,
        'autoResize' => FALSE,
        
// Attach the library necessary for using the OpenOffCanvasDialogCommand and     // set the attachments for this Ajax response.     $main_content['#attached']['library'][] = 'core/drupal.dialog.off_canvas';
    $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 OpenOffCanvasDialogCommand($title$content$options, NULL, $this->position));
    return $response;
  }

}
Home | Imprint | This part of the site doesn't use cookies.