function ResourceTestBase::grantIncludedPermissions

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::grantIncludedPermissions()
  2. 8.9.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::grantIncludedPermissions()
  3. 11.x core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::grantIncludedPermissions()

Grants authorization to view includes.

Parameters

string[] $include_paths: An array of include paths for which to grant access.

1 call to ResourceTestBase::grantIncludedPermissions()
ResourceTestBase::doTestIncluded in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
Tests included resources.

File

core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php, line 3520

Class

ResourceTestBase
Subclass this for every JSON:API resource type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

protected function grantIncludedPermissions(array $include_paths = []) {
    $applicable_permissions = array_intersect_key(static::getIncludePermissions(), array_flip($include_paths));
    $flattened_permissions = array_unique(array_reduce($applicable_permissions, 'array_merge', []));
    // Always grant access to 'view' the test entity reference field.
    $flattened_permissions[] = 'field_jsonapi_test_entity_ref view access';
    $this->grantPermissionsToTestedRole($flattened_permissions);
}

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