public function GroupHasNodeCondition::process in Business Rules 8
Same name and namespace in other branches
- 2.x modules/br_group/src/Plugin/BusinessRulesCondition/GroupHasNodeCondition.php \Drupal\br_group\Plugin\BusinessRulesCondition\GroupHasNodeCondition::process()
Process the condition.
Parameters
\Drupal\business_rules\ConditionInterface $condition: The configured condition.
\Drupal\business_rules\Events\BusinessRulesEvent $event: The event that has triggered the condition.
Return value
bool Boolean value that indicates if the condition is true.
Overrides BusinessRulesConditionPlugin::process
File
- modules/
br_group/ src/ Plugin/ BusinessRulesCondition/ GroupHasNodeCondition.php, line 58
Class
- GroupHasNodeCondition
- Class GroupHasNodeCondition.
Namespace
Drupal\br_group\Plugin\BusinessRulesConditionCode
public function process(ConditionInterface $condition, BusinessRulesEvent $event) {
$variables = $event
->getArgument('variables');
$group_id = $condition
->getSettings('group_id');
$group_id = $this
->processVariables($group_id, $variables);
$node_id = $condition
->getSettings('node_id');
$node_id = $this
->processVariables($node_id, $variables);
$node = Node::load($node_id);
if (!$node instanceof Node) {
return FALSE;
}
$group = Group::load($group_id);
$type = 'group_node:' . $node
->getType();
$content = $group
->getContent($type, [
'entity_id' => $node_id,
]);
if (count($content)) {
$result = TRUE;
}
else {
$result = FALSE;
}
return $result;
}