You are here

class GrantPromoteAccess in Override Node Options 8.3

Same name and namespace in other branches
  1. 8.2 src/Access/FieldAccess/GrantPromoteAccess.php \Drupal\override_node_options\Access\FieldAccess\GrantPromoteAccess

Hierarchy

Expanded class hierarchy of GrantPromoteAccess

1 file declares its use of GrantPromoteAccess
override_node_options.module in ./override_node_options.module
Main module file for override_node_options.

File

src/Access/FieldAccess/GrantPromoteAccess.php, line 7

Namespace

Drupal\override_node_options\Access\FieldAccess
View source
class GrantPromoteAccess extends AbstractFieldAccessOverride implements FieldAccessOverrideInterface {
  public static function access(array &$grants, array $context) {
    self::$context = $context;
    if (self::hasNodeEditPermission() && self::isFieldName('promote')) {
      $bundle = $context['items']
        ->getEntity()
        ->bundle();
      $grants[':default'] = AccessResult::allowedIfHasPermissions($context['account'], [
        "override {$bundle} promote to front page option",
        'override all promote to front page option',
      ], 'OR');
    }
  }

}

Members