class-otgs-installer-package.php
1.62 KB
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
<?php
class OTGS_Installer_Package {
private $key;
private $id;
private $name;
private $description;
private $image_url;
private $order;
private $parent;
private $products = array();
public function __construct( array $params = array() ) {
foreach ( get_object_vars( $this ) as $property => $value ) {
if ( array_key_exists( $property, $params ) ) {
$this->$property = $params[ $property ];
}
}
}
public function get_key() {
return $this->key;
}
public function get_products() {
return $this->products;
}
public function get_product_by_subscription_type( $type ) {
return $this->get_product_by( 'get_subscription_type', $type );
}
public function get_product_by_subscription_type_equivalent( $type ) {
return $this->get_product_by( 'get_subscription_type_equivalent', $type );
}
public function get_product_by( $function, $type ) {
foreach ( $this->products as $product ) {
if ( $type === $product->$function() ) {
return $product;
}
}
return null;
}
public function get_product_by_subscription_type_on_upgrades( $type ) {
foreach ( $this->products as $product ) {
foreach ( $product->get_upgrades() as $upgrade ) {
if ( $type === $upgrade['subscription_type'] ) {
return $product;
}
}
}
return null;
}
public function get_id() {
return $this->id;
}
public function get_name() {
return $this->name;
}
public function get_description() {
return $this->description;
}
public function get_image_url() {
return $this->image_url;
}
public function get_order() {
return $this->order;
}
public function get_parent() {
return $this->parent;
}
}