schemas
1 year ago
ActivatePlugin.php
1 year ago
ActivateTheme.php
1 year ago
InstallPlugin.php
1 year ago
InstallTheme.php
1 year ago
RunSql.php
1 year ago
SetSiteOptions.php
1 year ago
Step.php
1 year ago
SetSiteOptions.php
67 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Blueprint\Steps; |
| 4 | |
| 5 | /** |
| 6 | * Set site options step. |
| 7 | */ |
| 8 | class SetSiteOptions extends Step { |
| 9 | /** |
| 10 | * Site options. |
| 11 | * |
| 12 | * @var array site options |
| 13 | */ |
| 14 | private array $options; |
| 15 | |
| 16 | /** |
| 17 | * Constructor. |
| 18 | * |
| 19 | * @param array $options site options. |
| 20 | */ |
| 21 | public function __construct( array $options = array() ) { |
| 22 | $this->options = $options; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Get the name of the step. |
| 27 | * |
| 28 | * @return string step name |
| 29 | */ |
| 30 | public static function get_step_name(): string { |
| 31 | return 'setSiteOptions'; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get the schema for the step. |
| 36 | * |
| 37 | * @param int $version schema version. |
| 38 | * |
| 39 | * @return array schema for the step |
| 40 | */ |
| 41 | public static function get_schema( int $version = 1 ): array { |
| 42 | return array( |
| 43 | 'type' => 'object', |
| 44 | 'properties' => array( |
| 45 | 'step' => array( |
| 46 | 'type' => 'string', |
| 47 | 'enum' => array( static::get_step_name() ), |
| 48 | ), |
| 49 | |
| 50 | ), |
| 51 | 'required' => array( 'step' ), |
| 52 | ); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Prepare the step for JSON serialization. |
| 57 | * |
| 58 | * @return array array representation of the step |
| 59 | */ |
| 60 | public function prepare_json_array(): array { |
| 61 | return array( |
| 62 | 'step' => static::get_step_name(), |
| 63 | 'options' => (object) $this->options, |
| 64 | ); |
| 65 | } |
| 66 | } |
| 67 |