protected static function ProductVariationResourceTest::getAccessDeniedResponse in Commerce Core 8.2
Gets a generic forbidden response.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity for which to generate the forbidden response.
\Drupal\Core\Access\AccessResultInterface $access: The denied AccessResult. This can carry a reason and cacheability data.
\Drupal\Core\Url $via_link: The source URL for the errors of the response.
string|null $relationship_field_name: (optional) The field name to which the forbidden result applies. Useful for testing related/relationship routes and includes.
string|null $detail: (optional) Details for the JSON:API error object.
string|bool|null $pointer: (optional) Document pointer for the JSON:API error object. FALSE to omit the pointer.
Return value
\Drupal\jsonapi\ResourceResponse The forbidden ResourceResponse.
Overrides ResourceResponseTestTrait::getAccessDeniedResponse
File
- modules/
product/ tests/ src/ Functional/ Jsonapi/ ProductVariationResourceTest.php, line 315
Class
- ProductVariationResourceTest
- JSON:API resource test for variations.
Namespace
Drupal\Tests\commerce_product\Functional\JsonapiCode
protected static function getAccessDeniedResponse(EntityInterface $entity, AccessResultInterface $access, Url $via_link, $relationship_field_name = NULL, $detail = NULL, $pointer = NULL) {
// EntityAccessChecker returns the incorrect access reason for `view label`.
// @todo remove after https://www.drupal.org/project/drupal/issues/3163558
if ($access instanceof AccessResultReasonInterface && $via_link
->getRouteName() === 'jsonapi.commerce_product_variation_type--commerce_product_variation_type.individual' && !$access
->isAllowed()) {
$access
->setReason("The 'administer commerce_product_type' permission is required.");
}
return parent::getAccessDeniedResponse($entity, $access, $via_link, $relationship_field_name, $detail, $pointer);
}