Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EntityResource.php

function EntityResource::generateFallbackAccessDeniedMessage

Generates a fallback access denied message, when no specific reason is set.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

string $operation: The disallowed entity operation.

Return value

string The proper message to display in the AccessDeniedHttpException.

1 call to EntityResource::generateFallbackAccessDeniedMessage()
EntityResource::post in core/modules/rest/src/Plugin/rest/resource/EntityResource.php
Responds to entity POST requests and saves the new entity.

File

core/modules/rest/src/Plugin/rest/resource/EntityResource.php, line 350

Class

EntityResource
Represents entities as resources.

Namespace

Drupal\rest\Plugin\rest\resource

Code

protected function generateFallbackAccessDeniedMessage(EntityInterface $entity, $operation) {
    $message = "You are not authorized to {$operation} this {$entity->getEntityTypeId()} entity";
    if ($entity->bundle() !== $entity->getEntityTypeId()) {
        $message .= " of bundle {$entity->bundle()}";
    }
    return "{$message}.";
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal