/var/www/html_de/wp-content/plugins/woocommerce/packages/blueprint/src/Steps/ActivatePlugin.php


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
<?php

namespace Automattic\WooCommerce\Blueprint\Steps;

/**
 * Class ActivatePlugin
 *
 * @package Automattic\WooCommerce\Blueprint\Steps
 */
class ActivatePlugin extends Step {
    
/**
     * The name of the plugin to be activated.
     *
     * @var string The name of the plugin to be activated.
     */
    
private string $plugin_name;

    
/**
     * The path to the plugin file relative to the plugins directory.
     *
     * @var string  The path to the plugin file relative to the plugins directory.
     */
    
private string $plugin_path;

    
/**
     * ActivatePlugin constructor.
     *
     * @param string $plugin_path Path to the plugin file relative to the plugins directory.
     * @param string $plugin_name The name of the plugin to be activated.
     */
    
public function __construct$plugin_path$plugin_name '' ) {
        
$this->plugin_name $plugin_name;
        
$this->plugin_path $plugin_path;
    }

    
/**
     * Returns the name of this step.
     *
     * @return string The step name.
     */
    
public static function get_step_name(): string {
        return 
'activatePlugin';
    }

    
/**
     * 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_schemaint $version ): array {
        return array(
            
'type'       => 'object',
            
'properties' => array(
                
'step'       => array(
                    
'type' => 'string',
                    
'enum' => array( static::get_step_name() ),
                ),
                
'pluginName' => array(
                    
'type' => 'string',
                ),
                
'pluginPath' => array(
                    
'type' => 'string',
                ),
            ),
            
'required'   => array( 'step''pluginPath' ),
        );
    }

    
/**
     * Prepares an associative array for JSON encoding.
     *
     * @return array Array of data to be encoded as JSON.
     */
    
public function prepare_json_array(): array {
        
$data = array(
            
'step'       => static::get_step_name(),
            
'pluginPath' => $this->plugin_path,
        );

        if ( ! empty( 
$this->plugin_name ) ) {
            
$data['pluginName'] = $this->plugin_name;
        }

        return 
$data;
    }
}