You are here

protected function RuleGrantsOperationTrait::ruleGrantsOperation in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/RuleGrantsOperationTrait.php \Drupal\rng\RuleGrantsOperationTrait::ruleGrantsOperation()
  2. 3.x src/RuleGrantsOperationTrait.php \Drupal\rng\RuleGrantsOperationTrait::ruleGrantsOperation()

Checks if any operation actions on a rule grant $operation access.

This does not evaluate conditions.

Parameters

\Drupal\rng\RuleInterface $rule: A rule entity.

string $operation: A registration operation.

Return value

bool Whether $operation is granted by the actions.

2 calls to RuleGrantsOperationTrait::ruleGrantsOperation()
RegistrationAccessControlHandler::checkAccess in src/AccessControl/RegistrationAccessControlHandler.php
UserRNGSelection::buildEntityQuery in src/Plugin/EntityReferenceSelection/UserRNGSelection.php
Builds an EntityQuery to get referenceable entities.

File

src/RuleGrantsOperationTrait.php, line 23

Class

RuleGrantsOperationTrait
Defines a trait for working with 'registration operation' actions.

Namespace

Drupal\rng

Code

protected function ruleGrantsOperation(RuleInterface $rule, $operation) {
  $actions = $rule
    ->getActions();
  $operations_actions = array_filter($actions, function ($action) use ($actions, $operation) {
    if ($action
      ->getPluginId() == 'registration_operations') {
      $config = $action
        ->getConfiguration();
      return !empty($config['operations'][$operation]);
    }
    return FALSE;
  });
  return (bool) count($operations_actions);
}