You are here

public function NodeStatus::mayEditSetting in Fasttoggle 8.2

Access control function.

Parameters

$node: The node against which to check (un)publish permission.

Return value

boolean Whether the user is allowed to (un)publish the node.

Overrides SettingTrait::mayEditSetting

File

src/Plugin/Setting/NodeStatus.php, line 61
Fasttoggle Node Status

Class

NodeStatus
Abstract interface for settings. Plugin strings are used for quick filtering without the need to instantiate the class.

Namespace

Drupal\fasttoggle\Plugin\Setting

Code

public function mayEditSetting() {
  $user = \Drupal::currentUser();
  $config = \Drupal::config('fasttoggle.settings');
  $sitewide = $config
    ->get('node_core_status');
  $result = AccessResult::allowedIf($sitewide)
    ->addCacheableDependency($config)
    ->andIf(AccessResult::allowedIfHasPermission($user, [
    "override {$this->object->getType()} published option",
    'moderate posts',
  ], 'OR'));
  return $result;
}