function ContextualDynamicContextTest::renderContextualLinks

Same name in other branches
  1. 9 core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php \Drupal\Tests\contextual\Functional\ContextualDynamicContextTest::renderContextualLinks()
  2. 10 core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php \Drupal\Tests\contextual\Functional\ContextualDynamicContextTest::renderContextualLinks()
  3. 11.x core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php \Drupal\Tests\contextual\Functional\ContextualDynamicContextTest::renderContextualLinks()

Get server-rendered contextual links for the given contextual link ids.

Parameters

array $ids: An array of contextual link ids.

string $current_path: The Drupal path for the page for which the contextual links are rendered.

Return value

\Psr\Http\Message\ResponseInterface The response object.

1 call to ContextualDynamicContextTest::renderContextualLinks()
ContextualDynamicContextTest::testDifferentPermissions in core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php
Tests contextual links with different permissions.

File

core/modules/contextual/tests/src/Functional/ContextualDynamicContextTest.php, line 256

Class

ContextualDynamicContextTest
Tests if contextual links are showing on the front page depending on permissions.

Namespace

Drupal\Tests\contextual\Functional

Code

protected function renderContextualLinks($ids, $current_path) {
    $tokens = array_map([
        $this,
        'createContextualIdToken',
    ], $ids);
    $http_client = $this->getHttpClient();
    $url = Url::fromRoute('contextual.render', [], [
        'query' => [
            '_format' => 'json',
            'destination' => $current_path,
        ],
    ]);
    return $http_client->request('POST', $this->buildUrl($url), [
        'cookies' => $this->getSessionCookies(),
        'form_params' => [
            'ids' => $ids,
            'tokens' => $tokens,
        ],
        'http_errors' => FALSE,
    ]);
}

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