1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
<?php
namespace Automattic\WooCommerce\Blueprint\Steps;
/** * Class InstallTheme * * This class represents a step in the installation process of a WooCommerce theme. * It includes methods to prepare the data for the theme installation step and to provide * the schema for the JSON representation of this step. * * @package Automattic\WooCommerce\Blueprint\Steps */ class InstallTheme extends Step { /** * The slug of the theme to be installed. * * @var string The slug of the theme to be installed. */ private string $slug;
/** * The resource URL or path to the theme's ZIP file. * * @var string The resource URL or path to the theme's ZIP file. */ private string $resource;
/** * Additional options for the theme installation. * * @var array Additional options for the theme installation. */ private array $options;
/** * InstallTheme constructor. * * @param string $slug The slug of the theme to be installed. * @param string $resource The resource URL or path to the theme's ZIP file. * @param array $options Additional options for the theme installation. */ // phpcs:ignore public function __construct( $slug, $resource, array $options = array() ) { $this->slug = $slug; $this->resource = $resource; $this->options = $options; }
/** * Prepares an associative array for JSON encoding. * * @return array The JSON-encoded array representing this installation step. */ public function prepare_json_array(): array { return array( 'step' => static::get_step_name(), 'themeData' => array( 'resource' => $this->resource, 'slug' => $this->slug, ), 'options' => $this->options, ); }
/** * Returns the schema for the JSON representation of this step. * * @param int $version The version of the schema to return. * @return array The schema array. */ public static function get_schema( int $version = 1 ): array { return array( 'type' => 'object', 'properties' => array( 'step' => array( 'type' => 'string', 'enum' => array( static::get_step_name() ), ), 'themeData' => array( 'anyOf' => array( require __DIR__ . '/schemas/definitions/VFSReference.php', require __DIR__ . '/schemas/definitions/LiteralReference.php', require __DIR__ . '/schemas/definitions/CorePluginReference.php', require __DIR__ . '/schemas/definitions/CoreThemeReference.php', require __DIR__ . '/schemas/definitions/UrlReference.php', require __DIR__ . '/schemas/definitions/GitDirectoryReference.php', require __DIR__ . '/schemas/definitions/DirectoryLiteralReference.php', ), ), 'options' => array( 'type' => 'object', 'properties' => array( 'activate' => array( 'type' => 'boolean', ), ), ), ), 'required' => array( 'step', 'themeData' ), ); }
/** * Returns the name of this step. * * @return string The step name. */ public static function get_step_name(): string { return 'installTheme'; } }
|