- πΊπΈUnited States freelock Seattle
Hi,
Not an answer to this request, but a suggestion for an alternative: ECA module. ECA does everything Rules does, and the BPMN modeler even lets you do it visually as a flow chart.
We're using ECA with registration for a lot of tasks like the OP. There is one missing bit: ECA relies upon tokens to make entities available. We needed tokens for the host_entity and the registration settings entity, so we added to a custom module:
function mymodule_token_info_alter(&$data) { $data['tokens']['registration']['host_entity'] = [ 'name' => t('Host Entity'), 'description'=> t('Entity that this is attached to (usually node'), 'module' => 'mymodule', 'type' => 'node', ]; $data['tokens']['registration']['settings'] = [ 'name' => t('Registration Settings'), 'description'=> t('The Registration Settings for the entity this registration is attached to'), 'module' => 'mymodule', 'type' => 'registration_settings', ]; } function mymodule_tokens_alter(&$replacements, $context, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata ){ if ($context['type'] == 'registration'){ $tokens = $context['tokens']; foreach($tokens as $name => $original){ if(strpos($name, 'host_entity') === 0){ $field_tokens = \Drupal::token()->findWithPrefix($tokens, 'node'); $node = $context['data']['registration']->getHostEntity()->getEntity(); if ($name =='host_entity'){ $replacements[$original]= $node -> id(); } else { $replacements += \Drupal::token()->generate('node', $field_tokens, ['node'=> $node ], $context['options'], $bubbleable_metadata); } } if(strpos($name, 'settings') === 0){ $field_tokens = \Drupal::token()->findWithPrefix($tokens, 'settings'); $registration_settings = $context['data']['registration']->getHostEntity()->getSettings(); if($name =='settings'){ $replacements[$original]= $registration_settings -> id(); } else { $replacements += Drupal::token()->generate('registration_settings', $field_tokens,['registration_settings'=> $registration_settings], $context['options'], $bubbleable_metadata); } } $item = $context; } } }
- πΊπΈUnited States john.oltman
Thanks @freelock, I also prefer ECA over Rules. I may add a new Feature Request for full ECA integration.