public function NodePromotion::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/ NodePromotion.php, line 59 - Fasttoggle Node Promotion
Class
- NodePromotion
- Abstract interface for settings. Plugin strings are used for quick filtering without the need to instantiate the class.
Namespace
Drupal\fasttoggle\Plugin\SettingCode
public function mayEditSetting() {
$user = \Drupal::currentUser();
$config = \Drupal::config('fasttoggle.settings');
$sitewide = $config
->get('node_core_promoted');
$result = AccessResult::allowedIf($sitewide)
->addCacheableDependency($config)
->andIf(AccessResult::allowedIfHasPermission($user, [
"override {$this->object->getType()} promoted option",
'promote posts',
], 'OR'));
return $result;
}