You are here

trait RuleGrantsOperationTrait in RNG - Events and Registrations 3.x

Same name and namespace in other branches
  1. 8.2 src/RuleGrantsOperationTrait.php \Drupal\rng\RuleGrantsOperationTrait
  2. 8 src/RuleGrantsOperationTrait.php \Drupal\rng\RuleGrantsOperationTrait

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

Hierarchy

2 files declare their use of RuleGrantsOperationTrait
RegistrationAccessControlHandler.php in src/AccessControl/RegistrationAccessControlHandler.php
UserRNGSelection.php in src/Plugin/EntityReferenceSelection/UserRNGSelection.php

File

src/RuleGrantsOperationTrait.php, line 10

Namespace

Drupal\rng
View source
trait RuleGrantsOperationTrait {

  /**
   * Checks if any operation actions on a rule grant $operation access.
   *
   * This does not evaluate conditions.
   *
   * @param \Drupal\rng\RuleInterface $rule
   *   A rule entity.
   * @param string $operation
   *   A registration operation.
   *
   * @return bool
   *   Whether $operation is granted by the actions.
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RuleGrantsOperationTrait::ruleGrantsOperation protected function Checks if any operation actions on a rule grant $operation access.