protected function MaestroRulesActionSpawnWorkflow::doExecute in Maestro 3.x
Same name and namespace in other branches
- 8.2 src/Plugin/RulesAction/MaestroRulesActionSpawnWorkflow.php \Drupal\maestro\Plugin\RulesAction\MaestroRulesActionSpawnWorkflow::doExecute()
Spawns a workflow.
Parameters
string $template: The workflow template machine name you wish to spawn.
\Drupal\Core\Entity\EntityInterface $entity: The entity that is being saved.
File
- src/
Plugin/ RulesAction/ MaestroRulesActionSpawnWorkflow.php, line 40
Class
- MaestroRulesActionSpawnWorkflow
- Provides a 'Delete entity' action.
Namespace
Drupal\maestro\Plugin\RulesActionCode
protected function doExecute($template = NULL, EntityInterface $entity = NULL) {
if ($template !== NULL) {
$engine = new MaestroEngine();
$process_id = $engine
->newProcess($template);
if ($process_id) {
$entity_id = current($entity->nid
->getValue())['value'];
$entity_bundle = current($entity->type
->getValue())['target_id'];
MaestroEngine::createEntityIdentifier($process_id, 'node', $entity_bundle, 'rules_added_entity', $entity_id);
}
else {
// Error condition. The process was unable to be kicked off.
drupal_set_message(t('Unable to begin workflow. Please check with administrator for more information.'));
}
}
}