$step Normalized step. * @param array $context Execution context. * @param WorkflowJob|null $job Queue job. * @return ActionResult */ public function send( array $step, array $context, ?WorkflowJob $job = null ): ActionResult { $type = isset( $step['type'] ) ? (string) $step['type'] : ''; $actions = Actions::getActions(); if ( ! isset( $actions[ $type ]['action_class'] ) ) { return new ActionResult( false, sprintf( 'No local action registered for step type "%s".', $type ) ); } $class = $actions[ $type ]['action_class']; $action = new $class(); if ( 'send_email' === $type && empty( $step['template_id'] ) && ! empty( $step['email_template_id'] ) ) { $step['template_id'] = $step['email_template_id']; } try { $ok = $action->execute( $step, $context, $job ); } catch ( \Throwable $e ) { Log::error( 'ActionDispatcher: action threw', array( 'type' => $type, 'error' => $e->getMessage(), ) ); return new ActionResult( false, $e->getMessage(), array( 'exception' => get_class( $e ), ) ); } $errors = method_exists( $action, 'getExecutionErrors' ) ? (string) $action->getExecutionErrors() : ''; if ( true === $ok ) { return new ActionResult( true, '' !== $errors ? $errors : sprintf( 'Action %s completed.', $type ), array() ); } return new ActionResult( false, '' !== $errors ? $errors : sprintf( 'Action %s failed.', $type ), array() ); } }