RuleGrantsOperationTrait.php in RNG - Events and Registrations 8.2
Same filename and directory in other branches
Namespace
Drupal\rngFile
src/RuleGrantsOperationTrait.phpView source
<?php
namespace Drupal\rng;
use Drupal\rng\Entity\RuleInterface;
/**
* Defines a trait for working with 'registration operation' actions.
*/
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);
}
}
Traits
Name | Description |
---|---|
RuleGrantsOperationTrait | Defines a trait for working with 'registration operation' actions. |