protected function ParagraphAccessControlHandler::checkCreateAccess

File

paragraphs/src/ParagraphAccessControlHandler.php, line 80

Class

ParagraphAccessControlHandler
Access controller for the paragraphs entity.

Namespace

Drupal\paragraphs

Code

protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {

  // Allow paragraph entities to be created in the context of entity forms.
  if (\Drupal::requestStack()
    ->getCurrentRequest()
    ->getRequestFormat() === 'html') {
    return AccessResult::allowed()
      ->addCacheContexts([
      'request_format',
    ]);
  }
  return AccessResult::neutral()
    ->addCacheContexts([
    'request_format',
  ]);
}