class EntityAccessDeniedHttpExceptionNormalizer in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Normalizer/EntityAccessDeniedHttpExceptionNormalizer.php \Drupal\jsonapi\Normalizer\EntityAccessDeniedHttpExceptionNormalizer
Normalizes an EntityAccessDeniedException.
Normalizes an EntityAccessDeniedException in compliance with the JSON API specification. A source pointer is added to help client applications report which entity was access denied.
@internal
Hierarchy
- class \Drupal\serialization\Normalizer\NormalizerBase implements \Symfony\Component\Serializer\SerializerAwareInterface, CacheableNormalizerInterface uses \Symfony\Component\Serializer\SerializerAwareTrait
- class \Drupal\jsonapi\Normalizer\NormalizerBase
- class \Drupal\jsonapi\Normalizer\HttpExceptionNormalizer
- class \Drupal\jsonapi\Normalizer\EntityAccessDeniedHttpExceptionNormalizer
- class \Drupal\jsonapi\Normalizer\HttpExceptionNormalizer
- class \Drupal\jsonapi\Normalizer\NormalizerBase
Expanded class hierarchy of EntityAccessDeniedHttpExceptionNormalizer
See also
http://jsonapi.org/format/#error-objects
1 string reference to 'EntityAccessDeniedHttpExceptionNormalizer'
1 service uses EntityAccessDeniedHttpExceptionNormalizer
File
- src/
Normalizer/ EntityAccessDeniedHttpExceptionNormalizer.php, line 19
Namespace
Drupal\jsonapi\NormalizerView source
class EntityAccessDeniedHttpExceptionNormalizer extends HttpExceptionNormalizer {
/**
* {@inheritdoc}
*/
protected $supportedInterfaceOrClass = EntityAccessDeniedHttpException::class;
/**
* {@inheritdoc}
*/
protected function buildErrorObjects(HttpException $exception) {
$errors = parent::buildErrorObjects($exception);
if ($exception instanceof EntityAccessDeniedHttpException) {
$error = $exception
->getError();
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity = $error['entity'];
$pointer = $error['pointer'];
$reason = $error['reason'];
if (isset($entity)) {
$errors[0]['id'] = sprintf('/%s--%s/%s', $entity
->getEntityTypeId(), $entity
->bundle(), $entity
->uuid());
}
$errors[0]['source']['pointer'] = $pointer;
if ($reason) {
$errors[0]['detail'] = isset($errors[0]['detail']) ? $errors[0]['detail'] . ' ' . $reason : $reason;
}
}
return $errors;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableNormalizerInterface:: |
constant | Name of key for bubbling cacheability metadata via serialization context. | ||
EntityAccessDeniedHttpExceptionNormalizer:: |
protected | property |
The interface or class that this Normalizer supports. Overrides HttpExceptionNormalizer:: |
|
EntityAccessDeniedHttpExceptionNormalizer:: |
protected | function |
Builds the normalized JSON API error objects for the response. Overrides HttpExceptionNormalizer:: |
|
HttpExceptionNormalizer:: |
protected | property | The current user making the request. | |
HttpExceptionNormalizer:: |
public static | function | Return a string to the common problem type. | |
HttpExceptionNormalizer:: |
public | function | Normalizes an object into a set of arrays/scalars. | |
HttpExceptionNormalizer:: |
public | function | HttpExceptionNormalizer constructor. | |
NormalizerBase:: |
protected | property | List of formats which supports (de-)normalization. | 3 |
NormalizerBase:: |
protected | property | The formats that the Normalizer can handle. | 4 |
NormalizerBase:: |
protected | function | Adds cacheability if applicable. | |
NormalizerBase:: |
protected | function | Checks if the provided format is supported by this normalizer. | 2 |
NormalizerBase:: |
public | function |
Implements \Symfony\Component\Serializer\Normalizer\DenormalizerInterface::supportsDenormalization() Overrides NormalizerBase:: |
|
NormalizerBase:: |
public | function |
Checks whether the given class is supported for normalization by this normalizer. Overrides NormalizerBase:: |