graphql_core_schema-1.0.x-dev/modules/graphql_translatable_config_pages/graphql_translatable_config_pages.module
modules/graphql_translatable_config_pages/graphql_translatable_config_pages.module
<?php
declare(strict_types=1);
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
/**
* Implements hook_ENTITY_TYPE_access().
*/
function graphql_translatable_config_pages_translatable_config_pages_access(EntityInterface $entity, $operation, AccountInterface $account) {
// Custom access check for translatable_config_pages entities.
// All bundles can be viewed by anyone as they don't contain sensitive
// information. This allows GraphQL queries to access all config page bundles.
if ($operation === 'view') {
$bundle_info = \Drupal::service('entity_type.bundle.info')->getBundleInfo('translatable_config_pages');
$allowed_bundles = array_keys($bundle_info);
return AccessResult::allowedIf(in_array($entity->bundle(), $allowed_bundles));
}
return AccessResult::neutral();
}
