You are here

function yoast_seo_entity_field_access in Real-time SEO for Drupal 8

Same name and namespace in other branches
  1. 8.2 yoast_seo.module \yoast_seo_entity_field_access()

Implements hook_field_access().

File

./yoast_seo.module, line 66
Contains yoast_seo.module.

Code

function yoast_seo_entity_field_access($operation, $field_definition, $account, $items = NULL) {
  if ($field_definition
    ->getName() == 'field_yoast_seo') {
    return AccessResult::forbiddenIf(!($account
      ->hasPermission('use yoast seo') || $account
      ->hasPermission('administer yoast seo')) || !($account
      ->hasPermission('create url aliases') || $account
      ->hasPermission('administer url aliases')))
      ->cachePerPermissions();
  }

  // No opinion.
  return AccessResult::neutral();
}