function AjaxTestController::insertLinksInlineWrapper

Same name in other branches
  1. 9 core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::insertLinksInlineWrapper()
  2. 8.9.x core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::insertLinksInlineWrapper()
  3. 11.x core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php \Drupal\ajax_test\Controller\AjaxTestController::insertLinksInlineWrapper()

Returns a render array of links that directly Drupal.ajax().

Return value

array Renderable array of AJAX response contents.

1 string reference to 'AjaxTestController::insertLinksInlineWrapper'
ajax_test.routing.yml in core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml

File

core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php, line 109

Class

AjaxTestController
Provides content for dialog tests.

Namespace

Drupal\ajax_test\Controller

Code

public function insertLinksInlineWrapper() {
    $methods = [
        'html',
        'replaceWith',
    ];
    $build['links'] = [
        'ajax_target' => [
            '#markup' => '<div class="ajax-target-wrapper"><span id="ajax-target-inline">Target inline</span></div>',
        ],
        'links' => [
            '#theme' => 'links',
            '#attached' => [
                'library' => [
                    'ajax_test/ajax_insert',
                ],
            ],
        ],
    ];
    foreach ($methods as $method) {
        foreach ($this->getRenderTypes() as $type => $item) {
            $class = 'ajax-insert-inline';
            $build['links']['links']['#links']["{$method}-{$type}"] = [
                'title' => "Link {$method} {$type}",
                'url' => Url::fromRoute('ajax_test.ajax_render_types', [
                    'type' => $type,
                ]),
                'attributes' => [
                    'class' => [
                        $class,
                    ],
                    'data-method' => $method,
                    'data-effect' => $item['effect'],
                ],
            ];
        }
    }
    return $build;
}

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