You are here

protected function ActionCommonTrait::checkSetting in Content Access 8

Verifies that per content settings are activated for the given node.

2 calls to ActionCommonTrait::checkSetting()
ActionGrantNodePermissions::execute in src/Plugin/RulesAction/ActionGrantNodePermissions.php
Executes the plugin.
ActionRevokeNodePermissions::execute in src/Plugin/RulesAction/ActionRevokeNodePermissions.php
Executes the plugin.

File

src/Plugin/RulesAction/ActionCommonTrait.php, line 16

Class

ActionCommonTrait
Provides common functionality for Content Access Rules actions.

Namespace

Drupal\content_access\Plugin\RulesAction

Code

protected function checkSetting(NodeInterface $node) {
  $config = \Drupal::configFactory()
    ->getEditable('content_access.settings');
  $type = $node
    ->getType();
  $settings = unserialize($config
    ->get('content_access_node_type.' . $type));
  if (isset($settings['per_node']) && $settings['per_node']) {
    return TRUE;
  }

  // If we didn't find any settings in content access for this type return
  // false as we don't want to process it.
  $this->logger
    ->log(LogLevel::WARNING, $this
    ->t("Can't set per content permissions for content type @type. Make sure to have per content settings activated for content types you want to alter access control for.", [
    '@type' => $node
      ->getType(),
  ]));
  return FALSE;
}