You are here

public function NodeSticky::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/NodeSticky.php, line 59
Fasttoggle Node Sticky

Class

NodeSticky
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_sticky');
  $result = AccessResult::allowedIf($sitewide)
    ->addCacheableDependency($config)
    ->andIf(AccessResult::allowedIfHasPermission($user, [
    "override {$this->object->getType()} sticky option",
    'promote posts',
  ], 'OR'));
  return $result;
}