Action.php
11 months ago
Filter.php
2 years ago
Payload.php
3 years ago
Step.php
1 year ago
Subject.php
3 years ago
SubjectTransformer.php
2 years ago
Trigger.php
1 year ago
ValidationException.php
3 years ago
index.php
3 years ago
Step.php
74 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Automation\Engine\Integration; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Automation\Engine\Data\StepValidationArgs; |
| 9 | use MailPoet\Validator\Schema\ObjectSchema; |
| 10 | |
| 11 | /** |
| 12 | * Step Interface |
| 13 | * |
| 14 | * Defines the base contract for all automation steps in the MailPoet automation system. |
| 15 | * Can be either triggers, actions, or other step types. |
| 16 | */ |
| 17 | interface Step { |
| 18 | /** |
| 19 | * Get the unique identifier for this step type. |
| 20 | * |
| 21 | * This key is used to identify the step in the automation system and must be |
| 22 | * unique across all registered steps. It's typically in the format 'vendor:step-name'. |
| 23 | * |
| 24 | * @return string The unique step key |
| 25 | */ |
| 26 | public function getKey(): string; |
| 27 | |
| 28 | /** |
| 29 | * Get the human-readable name for this step. |
| 30 | * |
| 31 | * This name is displayed in the automation editor and should be translatable. |
| 32 | * |
| 33 | * @return string The step name |
| 34 | */ |
| 35 | public function getName(): string; |
| 36 | |
| 37 | /** |
| 38 | * Get the JSON schema for step configuration arguments. |
| 39 | * |
| 40 | * This schema defines the structure and validation rules for the step's |
| 41 | * configuration. It's used to validate step arguments during automation |
| 42 | * creation and to generate the UI for step configuration. |
| 43 | * |
| 44 | * @return ObjectSchema The JSON schema for step arguments |
| 45 | */ |
| 46 | public function getArgsSchema(): ObjectSchema; |
| 47 | |
| 48 | /** |
| 49 | * Get the subject keys that this step requires. |
| 50 | * |
| 51 | * Subjects represent data that flows through the automation. Each step |
| 52 | * declares which subjects it needs to function properly. The automation |
| 53 | * system ensures these subjects are available before the step executes. |
| 54 | * |
| 55 | * @return string[] Array of subject keys required by this step |
| 56 | */ |
| 57 | public function getSubjectKeys(): array; |
| 58 | |
| 59 | /** |
| 60 | * Validate the step configuration and context. |
| 61 | * |
| 62 | * This method is called during automation validation to ensure the step |
| 63 | * is properly configured and can execute successfully. It receives the |
| 64 | * automation context, step data, and available subjects for validation. |
| 65 | * |
| 66 | * Implementations should throw ValidationException if validation fails. |
| 67 | * |
| 68 | * @param StepValidationArgs $args Validation context containing automation, step, and subjects |
| 69 | * @return void |
| 70 | * @throws \MailPoet\Automation\Engine\Integration\ValidationException When validation fails |
| 71 | */ |
| 72 | public function validate(StepValidationArgs $args): void; |
| 73 | } |
| 74 |