| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup Wizard progressive step-save contracts. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Define one domain-owned Setup Wizard step save boundary. |
| 14 |
* |
| 15 |
* Implementations are responsible for their own capability, ownership, |
| 16 |
* edition, validation, canonical persistence, verification, and compensation. |
| 17 |
* The shared coordinator supplies already normalized wizard fields, but a |
| 18 |
* canonical handler must still revalidate every domain rule at apply time. |
| 19 |
*/ |
| 20 |
interface WPBC_Setup_Wizard_Step_Save_Handler { |
| 21 |
|
| 22 |
/** |
| 23 |
* Return the stable step identifier owned by this handler. |
| 24 |
* |
| 25 |
* @return string Stable step ID. |
| 26 |
*/ |
| 27 |
public function get_step_id(); |
| 28 |
|
| 29 |
/** |
| 30 |
* Return the server-owned primary action label for the current state. |
| 31 |
* |
| 32 |
* @param array<string,mixed> $checkpoint Current normalized checkpoint. |
| 33 |
* @param array<string,mixed> $step_context Authorized presentation context. |
| 34 |
* |
| 35 |
* @return string Translated primary action label. |
| 36 |
*/ |
| 37 |
public function get_primary_action_label( array $checkpoint, array $step_context = array() ); |
| 38 |
|
| 39 |
/** |
| 40 |
* Save one validated step through its domain boundary. |
| 41 |
* |
| 42 |
* @param array<string,mixed> $validated_fields Validated current-step fields. |
| 43 |
* @param array<string,mixed> $checkpoint Current normalized checkpoint. |
| 44 |
* @param array<string,mixed> $operation_context Stable operation metadata. |
| 45 |
* |
| 46 |
* @return array<string,mixed>|WP_Error Domain result or error. |
| 47 |
*/ |
| 48 |
public function save( array $validated_fields, array $checkpoint, array $operation_context ); |
| 49 |
|
| 50 |
/** |
| 51 |
* Determine whether a successful save completes the active route. |
| 52 |
* |
| 53 |
* @return bool True for a terminal step. |
| 54 |
*/ |
| 55 |
public function is_terminal(); |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Define the per-step operation lock required by the progressive coordinator. |
| 60 |
*/ |
| 61 |
interface WPBC_Setup_Wizard_Operation_Lock { |
| 62 |
|
| 63 |
/** |
| 64 |
* Acquire one context- and step-scoped operation lock. |
| 65 |
* |
| 66 |
* @param string $lock_scope Opaque checkpoint storage scope. |
| 67 |
* @param string $step_id Stable step identifier. |
| 68 |
* @param string $operation_id Stable operation identifier. |
| 69 |
* |
| 70 |
* @return string|WP_Error Opaque lock token or a busy error. |
| 71 |
*/ |
| 72 |
public function acquire( $lock_scope, $step_id, $operation_id ); |
| 73 |
|
| 74 |
/** |
| 75 |
* Release a lock only when the caller still owns its token. |
| 76 |
* |
| 77 |
* @param string $lock_scope Opaque checkpoint storage scope. |
| 78 |
* @param string $step_id Stable step identifier. |
| 79 |
* @param string $lock_token Opaque token returned by acquire(). |
| 80 |
* |
| 81 |
* @return void |
| 82 |
*/ |
| 83 |
public function release( $lock_scope, $step_id, $lock_token ); |
| 84 |
} |
| 85 |
|
| 86 |
|