@@ -30,86 +30,86 @@ |
||
30 | 30 | */ |
31 | 31 | class ConfirmDeletion |
32 | 32 | { |
33 | - /** |
|
34 | - * @var NodeGroupDao |
|
35 | - */ |
|
36 | - private $dao; |
|
33 | + /** |
|
34 | + * @var NodeGroupDao |
|
35 | + */ |
|
36 | + private $dao; |
|
37 | 37 | |
38 | - /** |
|
39 | - * ConfirmDeletion constructor. |
|
40 | - * @param NodeGroupDao $dao |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - NodeGroupDao $dao |
|
44 | - ) { |
|
38 | + /** |
|
39 | + * ConfirmDeletion constructor. |
|
40 | + * @param NodeGroupDao $dao |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + NodeGroupDao $dao |
|
44 | + ) { |
|
45 | 45 | |
46 | - $this->dao = $dao; |
|
47 | - } |
|
46 | + $this->dao = $dao; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion |
|
51 | - * preview page. |
|
52 | - * @since 4.10.12.p |
|
53 | - * @param $request_data |
|
54 | - * @param $admin_base_url |
|
55 | - * @throws EE_Error |
|
56 | - * @throws InvalidArgumentException |
|
57 | - * @throws InvalidDataTypeException |
|
58 | - * @throws InvalidInterfaceException |
|
59 | - * @throws ReflectionException |
|
60 | - * @throws UnexpectedEntityException |
|
61 | - */ |
|
62 | - public function handle($request_data, $admin_base_url) |
|
63 | - { |
|
64 | - $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
65 | - $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
66 | - $form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']); |
|
67 | - // Initialize the form from the request, and check if its valid. |
|
68 | - $form->receive_form_submission($request_data); |
|
69 | - if ($form->is_valid()) { |
|
70 | - // Redirect the user to the deletion batch job. |
|
71 | - EEH_URL::safeRedirectAndExit( |
|
72 | - EE_Admin_Page::add_query_args_and_nonce( |
|
73 | - array( |
|
74 | - 'page' => 'espresso_batch', |
|
75 | - 'batch' => EED_Batch::batch_job, |
|
76 | - 'deletion_job_code' => $deletion_job_code, |
|
77 | - 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'), |
|
78 | - 'return_url' => urlencode( |
|
79 | - add_query_arg( |
|
80 | - [ |
|
81 | - 'status' => 'trash' |
|
82 | - ], |
|
83 | - EVENTS_ADMIN_URL |
|
84 | - ) |
|
85 | - ) |
|
86 | - ), |
|
87 | - admin_url() |
|
88 | - ) |
|
89 | - ); |
|
90 | - } |
|
91 | - // Dont' use $form->submission_error_message() because it adds the form input's label in front |
|
92 | - // of each validation error which ends up looking quite confusing. |
|
93 | - $validation_errors = $form->get_validation_errors_accumulated(); |
|
94 | - foreach ($validation_errors as $validation_error) { |
|
95 | - EE_Error::add_error( |
|
96 | - $validation_error->getMessage(), |
|
97 | - __FILE__, |
|
98 | - __FUNCTION__, |
|
99 | - __LINE__ |
|
100 | - ); |
|
101 | - } |
|
49 | + /** |
|
50 | + * Redirects to the batch job for deleting events if the form submission is valid, otherwise back to the deletion |
|
51 | + * preview page. |
|
52 | + * @since 4.10.12.p |
|
53 | + * @param $request_data |
|
54 | + * @param $admin_base_url |
|
55 | + * @throws EE_Error |
|
56 | + * @throws InvalidArgumentException |
|
57 | + * @throws InvalidDataTypeException |
|
58 | + * @throws InvalidInterfaceException |
|
59 | + * @throws ReflectionException |
|
60 | + * @throws UnexpectedEntityException |
|
61 | + */ |
|
62 | + public function handle($request_data, $admin_base_url) |
|
63 | + { |
|
64 | + $deletion_job_code = isset($request_data['deletion_job_code']) ? sanitize_key($request_data['deletion_job_code']) : ''; |
|
65 | + $models_and_ids_to_delete = $this->dao->getModelsAndIdsFromGroup($deletion_job_code); |
|
66 | + $form = new ConfirmEventDeletionForm($models_and_ids_to_delete['Event']); |
|
67 | + // Initialize the form from the request, and check if its valid. |
|
68 | + $form->receive_form_submission($request_data); |
|
69 | + if ($form->is_valid()) { |
|
70 | + // Redirect the user to the deletion batch job. |
|
71 | + EEH_URL::safeRedirectAndExit( |
|
72 | + EE_Admin_Page::add_query_args_and_nonce( |
|
73 | + array( |
|
74 | + 'page' => 'espresso_batch', |
|
75 | + 'batch' => EED_Batch::batch_job, |
|
76 | + 'deletion_job_code' => $deletion_job_code, |
|
77 | + 'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'), |
|
78 | + 'return_url' => urlencode( |
|
79 | + add_query_arg( |
|
80 | + [ |
|
81 | + 'status' => 'trash' |
|
82 | + ], |
|
83 | + EVENTS_ADMIN_URL |
|
84 | + ) |
|
85 | + ) |
|
86 | + ), |
|
87 | + admin_url() |
|
88 | + ) |
|
89 | + ); |
|
90 | + } |
|
91 | + // Dont' use $form->submission_error_message() because it adds the form input's label in front |
|
92 | + // of each validation error which ends up looking quite confusing. |
|
93 | + $validation_errors = $form->get_validation_errors_accumulated(); |
|
94 | + foreach ($validation_errors as $validation_error) { |
|
95 | + EE_Error::add_error( |
|
96 | + $validation_error->getMessage(), |
|
97 | + __FILE__, |
|
98 | + __FUNCTION__, |
|
99 | + __LINE__ |
|
100 | + ); |
|
101 | + } |
|
102 | 102 | |
103 | - EEH_URL::safeRedirectAndExit( |
|
104 | - EE_Admin_Page::add_query_args_and_nonce( |
|
105 | - [ |
|
106 | - 'action' => 'preview_deletion', |
|
107 | - 'deletion_job_code' => $deletion_job_code |
|
108 | - ], |
|
109 | - $admin_base_url |
|
110 | - ) |
|
111 | - ); |
|
112 | - } |
|
103 | + EEH_URL::safeRedirectAndExit( |
|
104 | + EE_Admin_Page::add_query_args_and_nonce( |
|
105 | + [ |
|
106 | + 'action' => 'preview_deletion', |
|
107 | + 'deletion_job_code' => $deletion_job_code |
|
108 | + ], |
|
109 | + $admin_base_url |
|
110 | + ) |
|
111 | + ); |
|
112 | + } |
|
113 | 113 | } |
114 | 114 | // End of file ConfirmDeletion.php |
115 | 115 | // Location: EventEspresso\core\domain\services\admin\events\data/ConfirmDeletion.php |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function get_table_name() |
95 | 95 | { |
96 | - return $this->get_table_prefix() . $this->_table_name; |
|
96 | + return $this->get_table_prefix().$this->_table_name; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function get_table_alias() |
107 | 107 | { |
108 | - if (! $this->_table_alias) { |
|
108 | + if ( ! $this->_table_alias) { |
|
109 | 109 | throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
110 | 110 | } |
111 | 111 | return $this->_table_alias; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | public function get_fully_qualified_pk_column() |
130 | 130 | { |
131 | - return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | + return $this->get_table_alias().".".$this->get_pk_column(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function get_select_join_limit($limit) |
141 | 141 | { |
142 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
143 | - return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
142 | + $limit = is_array($limit) ? 'LIMIT '.implode(',', array_map('intval', $limit)) : 'LIMIT '.(int) $limit; |
|
143 | + return SP.'(SELECT * FROM '.$this->_table_name.SP.$limit.') AS '.$this->_table_alias; |
|
144 | 144 | } |
145 | 145 | |
146 | 146 |
@@ -6,151 +6,151 @@ |
||
6 | 6 | */ |
7 | 7 | abstract class EE_Table_Base |
8 | 8 | { |
9 | - /** |
|
10 | - * This holds the table_name without the table prefix. |
|
11 | - * |
|
12 | - * @var string |
|
13 | - */ |
|
14 | - public $_table_name; |
|
15 | - |
|
16 | - |
|
17 | - /** |
|
18 | - * This holds what is used as the alias for the table in queries. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - public $_table_alias; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * Table's private key column |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $_pk_column; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Whether this table is a global table (in multisite) or specific to site. |
|
35 | - * |
|
36 | - * @var bool |
|
37 | - */ |
|
38 | - protected $_global; |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $table_name with or without wpdb prefix |
|
43 | - * @param string $pk_column |
|
44 | - * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
45 | - * install, or whether each site on a multisite install has a copy of this table |
|
46 | - * @global wpdb $wpdb |
|
47 | - */ |
|
48 | - public function __construct($table_name, $pk_column, $global = false) |
|
49 | - { |
|
50 | - $this->_global = $global; |
|
51 | - $prefix = $this->get_table_prefix(); |
|
52 | - // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
53 | - if (strpos($table_name, $prefix) === 0) { |
|
54 | - $table_name = substr_replace($table_name, '', 0, strlen($prefix)); |
|
55 | - } |
|
56 | - $this->_table_name = $table_name; |
|
57 | - $this->_pk_column = $pk_column; |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * This returns the table prefix for the current model state. |
|
63 | - * |
|
64 | - * @return string |
|
65 | - * @global wpdb $wpdb |
|
66 | - */ |
|
67 | - public function get_table_prefix() |
|
68 | - { |
|
69 | - global $wpdb; |
|
70 | - if ($this->_global) { |
|
71 | - return $wpdb->base_prefix; |
|
72 | - } |
|
73 | - return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
74 | - } |
|
75 | - |
|
76 | - |
|
77 | - /** |
|
78 | - * Used to set the table_alias property |
|
79 | - * |
|
80 | - * @param string $table_alias |
|
81 | - */ |
|
82 | - public function _construct_finalize_with_alias($table_alias) |
|
83 | - { |
|
84 | - $this->_table_alias = $table_alias; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
90 | - * |
|
91 | - * @return string |
|
92 | - */ |
|
93 | - public function get_table_name() |
|
94 | - { |
|
95 | - return $this->get_table_prefix() . $this->_table_name; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Provides what is currently set as the alias for the table to be used in queries. |
|
101 | - * |
|
102 | - * @return string |
|
103 | - * @throws EE_Error |
|
104 | - */ |
|
105 | - public function get_table_alias() |
|
106 | - { |
|
107 | - if (! $this->_table_alias) { |
|
108 | - throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
109 | - } |
|
110 | - return $this->_table_alias; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @return string name of column of PK |
|
116 | - */ |
|
117 | - public function get_pk_column() |
|
118 | - { |
|
119 | - return $this->_pk_column; |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * returns a string with the table alias, a period, and the private key's column. |
|
125 | - * |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function get_fully_qualified_pk_column() |
|
129 | - { |
|
130 | - return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * returns the special sql for a inner select with a limit. |
|
136 | - * |
|
137 | - * @return string SQL select |
|
138 | - */ |
|
139 | - public function get_select_join_limit($limit) |
|
140 | - { |
|
141 | - $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
142 | - return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * Returns whether or not htis is a global table (ie, on multisite there's |
|
148 | - * only one of these tables, on the main blog) |
|
149 | - * |
|
150 | - * @return boolean |
|
151 | - */ |
|
152 | - public function is_global() |
|
153 | - { |
|
154 | - return $this->_global; |
|
155 | - } |
|
9 | + /** |
|
10 | + * This holds the table_name without the table prefix. |
|
11 | + * |
|
12 | + * @var string |
|
13 | + */ |
|
14 | + public $_table_name; |
|
15 | + |
|
16 | + |
|
17 | + /** |
|
18 | + * This holds what is used as the alias for the table in queries. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + public $_table_alias; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * Table's private key column |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $_pk_column; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Whether this table is a global table (in multisite) or specific to site. |
|
35 | + * |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | + protected $_global; |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $table_name with or without wpdb prefix |
|
43 | + * @param string $pk_column |
|
44 | + * @param boolean $global whether the table is "global" as in there is only 1 table on an entire multisite |
|
45 | + * install, or whether each site on a multisite install has a copy of this table |
|
46 | + * @global wpdb $wpdb |
|
47 | + */ |
|
48 | + public function __construct($table_name, $pk_column, $global = false) |
|
49 | + { |
|
50 | + $this->_global = $global; |
|
51 | + $prefix = $this->get_table_prefix(); |
|
52 | + // if they added the prefix, let's remove it because we delay adding the prefix until right when its needed. |
|
53 | + if (strpos($table_name, $prefix) === 0) { |
|
54 | + $table_name = substr_replace($table_name, '', 0, strlen($prefix)); |
|
55 | + } |
|
56 | + $this->_table_name = $table_name; |
|
57 | + $this->_pk_column = $pk_column; |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * This returns the table prefix for the current model state. |
|
63 | + * |
|
64 | + * @return string |
|
65 | + * @global wpdb $wpdb |
|
66 | + */ |
|
67 | + public function get_table_prefix() |
|
68 | + { |
|
69 | + global $wpdb; |
|
70 | + if ($this->_global) { |
|
71 | + return $wpdb->base_prefix; |
|
72 | + } |
|
73 | + return $wpdb->get_blog_prefix(EEM_Base::get_model_query_blog_id()); |
|
74 | + } |
|
75 | + |
|
76 | + |
|
77 | + /** |
|
78 | + * Used to set the table_alias property |
|
79 | + * |
|
80 | + * @param string $table_alias |
|
81 | + */ |
|
82 | + public function _construct_finalize_with_alias($table_alias) |
|
83 | + { |
|
84 | + $this->_table_alias = $table_alias; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * Returns the fully qualified table name for the database (includes the table prefix current for the blog). |
|
90 | + * |
|
91 | + * @return string |
|
92 | + */ |
|
93 | + public function get_table_name() |
|
94 | + { |
|
95 | + return $this->get_table_prefix() . $this->_table_name; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Provides what is currently set as the alias for the table to be used in queries. |
|
101 | + * |
|
102 | + * @return string |
|
103 | + * @throws EE_Error |
|
104 | + */ |
|
105 | + public function get_table_alias() |
|
106 | + { |
|
107 | + if (! $this->_table_alias) { |
|
108 | + throw new EE_Error("You must call _construct_finalize_with_alias before using the EE_Table_Base. Did you forget to call parent::__construct at the end of your EEMerimental_Base child's __construct?"); |
|
109 | + } |
|
110 | + return $this->_table_alias; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @return string name of column of PK |
|
116 | + */ |
|
117 | + public function get_pk_column() |
|
118 | + { |
|
119 | + return $this->_pk_column; |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * returns a string with the table alias, a period, and the private key's column. |
|
125 | + * |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function get_fully_qualified_pk_column() |
|
129 | + { |
|
130 | + return $this->get_table_alias() . "." . $this->get_pk_column(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * returns the special sql for a inner select with a limit. |
|
136 | + * |
|
137 | + * @return string SQL select |
|
138 | + */ |
|
139 | + public function get_select_join_limit($limit) |
|
140 | + { |
|
141 | + $limit = is_array($limit) ? 'LIMIT ' . implode(',', array_map('intval', $limit)) : 'LIMIT ' . (int) $limit; |
|
142 | + return SP . '(SELECT * FROM ' . $this->_table_name . SP . $limit . ') AS ' . $this->_table_alias; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * Returns whether or not htis is a global table (ie, on multisite there's |
|
148 | + * only one of these tables, on the main blog) |
|
149 | + * |
|
150 | + * @return boolean |
|
151 | + */ |
|
152 | + public function is_global() |
|
153 | + { |
|
154 | + return $this->_global; |
|
155 | + } |
|
156 | 156 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
41 | 41 | { |
42 | - if (! isset($arguments[0], $arguments[1])) { |
|
42 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
43 | 43 | throw new InvalidArgumentException( |
44 | 44 | esc_html__( |
45 | 45 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | /** @var DomainInterface $domain */ |
51 | 51 | $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
52 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | + if ( ! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
53 | 53 | throw new DomainException( |
54 | 54 | sprintf( |
55 | 55 | esc_html__( |
@@ -22,62 +22,62 @@ |
||
22 | 22 | */ |
23 | 23 | class DomainFactory |
24 | 24 | { |
25 | - /** |
|
26 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
27 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
28 | - * constructor. Must at least include the following two value objects: |
|
29 | - * array( |
|
30 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
31 | - * EventEspresso\core\domain\values\Version $version |
|
32 | - * ) |
|
33 | - * @return DomainInterface |
|
34 | - * @throws DomainException |
|
35 | - * @throws InvalidArgumentException |
|
36 | - * @throws InvalidDataTypeException |
|
37 | - * @throws InvalidInterfaceException |
|
38 | - */ |
|
39 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
40 | - { |
|
41 | - if (! isset($arguments[0], $arguments[1])) { |
|
42 | - throw new InvalidArgumentException( |
|
43 | - esc_html__( |
|
44 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
45 | - 'event_espresso' |
|
46 | - ) |
|
47 | - ); |
|
48 | - } |
|
49 | - /** @var DomainInterface $domain */ |
|
50 | - $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
51 | - if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | - throw new DomainException( |
|
53 | - sprintf( |
|
54 | - esc_html__( |
|
55 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - $domain_fqcn |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
62 | - return $domain; |
|
63 | - } |
|
25 | + /** |
|
26 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
27 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
28 | + * constructor. Must at least include the following two value objects: |
|
29 | + * array( |
|
30 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
31 | + * EventEspresso\core\domain\values\Version $version |
|
32 | + * ) |
|
33 | + * @return DomainInterface |
|
34 | + * @throws DomainException |
|
35 | + * @throws InvalidArgumentException |
|
36 | + * @throws InvalidDataTypeException |
|
37 | + * @throws InvalidInterfaceException |
|
38 | + */ |
|
39 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments) |
|
40 | + { |
|
41 | + if (! isset($arguments[0], $arguments[1])) { |
|
42 | + throw new InvalidArgumentException( |
|
43 | + esc_html__( |
|
44 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
45 | + 'event_espresso' |
|
46 | + ) |
|
47 | + ); |
|
48 | + } |
|
49 | + /** @var DomainInterface $domain */ |
|
50 | + $domain = LoaderFactory::getLoader()->getShared($domain_fqcn, $arguments); |
|
51 | + if (! $domain instanceof $domain_fqcn && ! $domain instanceof DomainBase) { |
|
52 | + throw new DomainException( |
|
53 | + sprintf( |
|
54 | + esc_html__( |
|
55 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + $domain_fqcn |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | + return $domain; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @return Domain |
|
68 | - * @throws DomainException |
|
69 | - * @throws InvalidArgumentException |
|
70 | - * @throws InvalidDataTypeException |
|
71 | - * @throws InvalidFilePathException |
|
72 | - * @throws InvalidInterfaceException |
|
73 | - */ |
|
74 | - public static function getEventEspressoCoreDomain() |
|
75 | - { |
|
76 | - $domain = new Domain( |
|
77 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
78 | - Version::fromString(espresso_version()) |
|
79 | - ); |
|
80 | - LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
81 | - return $domain; |
|
82 | - } |
|
66 | + /** |
|
67 | + * @return Domain |
|
68 | + * @throws DomainException |
|
69 | + * @throws InvalidArgumentException |
|
70 | + * @throws InvalidDataTypeException |
|
71 | + * @throws InvalidFilePathException |
|
72 | + * @throws InvalidInterfaceException |
|
73 | + */ |
|
74 | + public static function getEventEspressoCoreDomain() |
|
75 | + { |
|
76 | + $domain = new Domain( |
|
77 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
78 | + Version::fromString(espresso_version()) |
|
79 | + ); |
|
80 | + LoaderFactory::getLoader()->share('EventEspresso\core\domain\Domain', $domain); |
|
81 | + return $domain; |
|
82 | + } |
|
83 | 83 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($identifier = '', array $setup_args = []) |
30 | 30 | { |
31 | - self::$exporters[ $identifier ] = $setup_args; |
|
31 | + self::$exporters[$identifier] = $setup_args; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($identifier = '') |
44 | 44 | { |
45 | - unset(self::$exporters[ $identifier ]); |
|
45 | + unset(self::$exporters[$identifier]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -12,55 +12,55 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Personal_Data_Exporter implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $exporters = []; |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $exporters = []; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $identifier |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - */ |
|
28 | - public static function register($identifier = '', array $setup_args = []) |
|
29 | - { |
|
30 | - self::$exporters[ $identifier ] = $setup_args; |
|
31 | - // add to list of modules to be registered |
|
32 | - add_filter( |
|
33 | - 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
34 | - ['EE_Register_Personal_Data_Exporter', 'addExporters'] |
|
35 | - ); |
|
36 | - } |
|
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + */ |
|
28 | + public static function register($identifier = '', array $setup_args = []) |
|
29 | + { |
|
30 | + self::$exporters[ $identifier ] = $setup_args; |
|
31 | + // add to list of modules to be registered |
|
32 | + add_filter( |
|
33 | + 'FHEE__EventEspresso_core_services_privacy_export_PersonalDataExporterManager__exporters', |
|
34 | + ['EE_Register_Personal_Data_Exporter', 'addExporters'] |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param string $identifier |
|
41 | - */ |
|
42 | - public static function deregister($identifier = '') |
|
43 | - { |
|
44 | - unset(self::$exporters[ $identifier ]); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string $identifier |
|
41 | + */ |
|
42 | + public static function deregister($identifier = '') |
|
43 | + { |
|
44 | + unset(self::$exporters[ $identifier ]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Adds our personal data exporters registered by add-ons |
|
50 | - * |
|
51 | - * @param string[] $exporters |
|
52 | - * @return string[] |
|
53 | - */ |
|
54 | - public static function addExporters(array $exporters) |
|
55 | - { |
|
56 | - foreach (self::$exporters as $exporters_per_addon) { |
|
57 | - $exporters = array_merge( |
|
58 | - $exporters, |
|
59 | - $exporters_per_addon |
|
60 | - ); |
|
61 | - } |
|
62 | - return $exporters; |
|
63 | - } |
|
48 | + /** |
|
49 | + * Adds our personal data exporters registered by add-ons |
|
50 | + * |
|
51 | + * @param string[] $exporters |
|
52 | + * @return string[] |
|
53 | + */ |
|
54 | + public static function addExporters(array $exporters) |
|
55 | + { |
|
56 | + foreach (self::$exporters as $exporters_per_addon) { |
|
57 | + $exporters = array_merge( |
|
58 | + $exporters, |
|
59 | + $exporters_per_addon |
|
60 | + ); |
|
61 | + } |
|
62 | + return $exporters; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | // End of file EE_Register_Personal_Data_Exporter.lib.php |
66 | 66 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Exporter.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($identifier = '', array $setup_args = []) |
30 | 30 | { |
31 | - self::$erasers[ $identifier ] = $setup_args; |
|
31 | + self::$erasers[$identifier] = $setup_args; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($identifier = '') |
44 | 44 | { |
45 | - unset(self::$erasers[ $identifier ]); |
|
45 | + unset(self::$erasers[$identifier]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -12,55 +12,55 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Personal_Data_Eraser implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $erasers = []; |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $erasers = []; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $identifier |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - */ |
|
28 | - public static function register($identifier = '', array $setup_args = []) |
|
29 | - { |
|
30 | - self::$erasers[ $identifier ] = $setup_args; |
|
31 | - // add to list of modules to be registered |
|
32 | - add_filter( |
|
33 | - 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
34 | - ['EE_Register_Personal_Data_Eraser', 'addErasers'] |
|
35 | - ); |
|
36 | - } |
|
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + */ |
|
28 | + public static function register($identifier = '', array $setup_args = []) |
|
29 | + { |
|
30 | + self::$erasers[ $identifier ] = $setup_args; |
|
31 | + // add to list of modules to be registered |
|
32 | + add_filter( |
|
33 | + 'FHEE__EventEspresso_core_services_privacy_erasure_PersonalDataEraserManager__erasers', |
|
34 | + ['EE_Register_Personal_Data_Eraser', 'addErasers'] |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param string $identifier |
|
41 | - */ |
|
42 | - public static function deregister($identifier = '') |
|
43 | - { |
|
44 | - unset(self::$erasers[ $identifier ]); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string $identifier |
|
41 | + */ |
|
42 | + public static function deregister($identifier = '') |
|
43 | + { |
|
44 | + unset(self::$erasers[ $identifier ]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Adds our personal data erasers registered by add-ons |
|
50 | - * |
|
51 | - * @param string[] $erasers |
|
52 | - * @return string[] |
|
53 | - */ |
|
54 | - public static function addErasers(array $erasers) |
|
55 | - { |
|
56 | - foreach (self::$erasers as $erasers_per_addon) { |
|
57 | - $erasers = array_merge( |
|
58 | - $erasers, |
|
59 | - $erasers_per_addon |
|
60 | - ); |
|
61 | - } |
|
62 | - return $erasers; |
|
63 | - } |
|
48 | + /** |
|
49 | + * Adds our personal data erasers registered by add-ons |
|
50 | + * |
|
51 | + * @param string[] $erasers |
|
52 | + * @return string[] |
|
53 | + */ |
|
54 | + public static function addErasers(array $erasers) |
|
55 | + { |
|
56 | + foreach (self::$erasers as $erasers_per_addon) { |
|
57 | + $erasers = array_merge( |
|
58 | + $erasers, |
|
59 | + $erasers_per_addon |
|
60 | + ); |
|
61 | + } |
|
62 | + return $erasers; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | // End of file EE_Register_Personal_Data_Eraser.lib.php |
66 | 66 | // Location: ${NAMESPACE}/EE_Register_Personal_Data_Eraser.lib.php |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public static function register($identifier = '', array $setup_args = []) |
30 | 30 | { |
31 | - self::$privacy_policies[ $identifier ] = $setup_args; |
|
31 | + self::$privacy_policies[$identifier] = $setup_args; |
|
32 | 32 | // add to list of modules to be registered |
33 | 33 | add_filter( |
34 | 34 | 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public static function deregister($identifier = '') |
44 | 44 | { |
45 | - unset(self::$privacy_policies[ $identifier ]); |
|
45 | + unset(self::$privacy_policies[$identifier]); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |
@@ -12,55 +12,55 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_Register_Privacy_Policy implements EEI_Plugin_API |
14 | 14 | { |
15 | - /** |
|
16 | - * FQCN for all privacy policy generators |
|
17 | - * |
|
18 | - * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | - */ |
|
20 | - protected static $privacy_policies = array(); |
|
15 | + /** |
|
16 | + * FQCN for all privacy policy generators |
|
17 | + * |
|
18 | + * @var array keys are plugin_ids, and values are an array of FQCNs or FQCNs |
|
19 | + */ |
|
20 | + protected static $privacy_policies = array(); |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $identifier |
|
25 | - * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | - * OR fully qualified class names of privacy policies |
|
27 | - */ |
|
28 | - public static function register($identifier = '', array $setup_args = []) |
|
29 | - { |
|
30 | - self::$privacy_policies[ $identifier ] = $setup_args; |
|
31 | - // add to list of modules to be registered |
|
32 | - add_filter( |
|
33 | - 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
34 | - array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
35 | - ); |
|
36 | - } |
|
23 | + /** |
|
24 | + * @param string $identifier |
|
25 | + * @param array $setup_args can be the fully qualified namespaces each containing only privacy policies, |
|
26 | + * OR fully qualified class names of privacy policies |
|
27 | + */ |
|
28 | + public static function register($identifier = '', array $setup_args = []) |
|
29 | + { |
|
30 | + self::$privacy_policies[ $identifier ] = $setup_args; |
|
31 | + // add to list of modules to be registered |
|
32 | + add_filter( |
|
33 | + 'FHEE__EventEspresso_core_services_privacy_policy_PrivacyPolicyManager__privacy_policies', |
|
34 | + array('EE_Register_Privacy_Policy', 'addPrivacyPolicies') |
|
35 | + ); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @param string $identifier |
|
41 | - */ |
|
42 | - public static function deregister($identifier = '') |
|
43 | - { |
|
44 | - unset(self::$privacy_policies[ $identifier ]); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param string $identifier |
|
41 | + */ |
|
42 | + public static function deregister($identifier = '') |
|
43 | + { |
|
44 | + unset(self::$privacy_policies[ $identifier ]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * Adds our privacy policy generators registered by add-ons |
|
50 | - * |
|
51 | - * @param string[] $privacy_policies |
|
52 | - * @return string[] |
|
53 | - */ |
|
54 | - public static function addPrivacyPolicies(array $privacy_policies) |
|
55 | - { |
|
56 | - foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
57 | - $privacy_policies = array_merge( |
|
58 | - $privacy_policies, |
|
59 | - $privacy_policies_per_addon |
|
60 | - ); |
|
61 | - } |
|
62 | - return $privacy_policies; |
|
63 | - } |
|
48 | + /** |
|
49 | + * Adds our privacy policy generators registered by add-ons |
|
50 | + * |
|
51 | + * @param string[] $privacy_policies |
|
52 | + * @return string[] |
|
53 | + */ |
|
54 | + public static function addPrivacyPolicies(array $privacy_policies) |
|
55 | + { |
|
56 | + foreach (self::$privacy_policies as $privacy_policies_per_addon) { |
|
57 | + $privacy_policies = array_merge( |
|
58 | + $privacy_policies, |
|
59 | + $privacy_policies_per_addon |
|
60 | + ); |
|
61 | + } |
|
62 | + return $privacy_policies; |
|
63 | + } |
|
64 | 64 | } |
65 | 65 | // End of file EE_Register_Privacy_Policy.lib.php |
66 | 66 | // Location: ${NAMESPACE}/EE_Register_Privacy_Policy.lib.php |
@@ -15,137 +15,137 @@ |
||
15 | 15 | */ |
16 | 16 | class ActivationTypeDetector |
17 | 17 | { |
18 | - /** |
|
19 | - * Determines the activation type for EE core or any EE addon, given three pieces of info: |
|
20 | - * the current array of activation histories |
|
21 | - * (for core that' 'espresso_db_update' wp option); |
|
22 | - * the name of the WordPress option which is temporarily set upon activation of the plugin |
|
23 | - * (for core it's 'ee_espresso_activation'); |
|
24 | - * and the version that this plugin was just activated to |
|
25 | - * (for core that will always be espresso_version()) |
|
26 | - * |
|
27 | - * @param ActivationHistory $activation_history |
|
28 | - * @return ActivationType |
|
29 | - * @throws InvalidArgumentException |
|
30 | - */ |
|
31 | - public function resolveActivationTypeFromActivationHistory(ActivationHistory $activation_history): ActivationType |
|
32 | - { |
|
33 | - $version_history = $activation_history->getVersionHistory(); |
|
34 | - // if $version_history does NOT exist, then this is a completely NEW install |
|
35 | - if (empty($version_history)) { |
|
36 | - return $this->newActivation($activation_history); |
|
37 | - } |
|
38 | - // NOT a new install, so check for a version change |
|
39 | - $version_change = $this->versionChange($activation_history); |
|
40 | - if ($version_change !== 0) { |
|
41 | - return $this->upgradeOrDowngrade($activation_history, $version_change); |
|
42 | - } |
|
43 | - // we've seen this version before, but its not an upgrade or downgrade, so maybe a reactivation? |
|
44 | - if ($activation_history->getActivationIndicator()) { |
|
45 | - return $this->reactivation($activation_history); |
|
46 | - } |
|
47 | - // not an activation. just a normal request |
|
48 | - return new ActivationType( |
|
49 | - ActivationType::NOT_ACTIVATION, |
|
50 | - $this->detectMajorVersionChange($activation_history) |
|
51 | - ); |
|
52 | - } |
|
18 | + /** |
|
19 | + * Determines the activation type for EE core or any EE addon, given three pieces of info: |
|
20 | + * the current array of activation histories |
|
21 | + * (for core that' 'espresso_db_update' wp option); |
|
22 | + * the name of the WordPress option which is temporarily set upon activation of the plugin |
|
23 | + * (for core it's 'ee_espresso_activation'); |
|
24 | + * and the version that this plugin was just activated to |
|
25 | + * (for core that will always be espresso_version()) |
|
26 | + * |
|
27 | + * @param ActivationHistory $activation_history |
|
28 | + * @return ActivationType |
|
29 | + * @throws InvalidArgumentException |
|
30 | + */ |
|
31 | + public function resolveActivationTypeFromActivationHistory(ActivationHistory $activation_history): ActivationType |
|
32 | + { |
|
33 | + $version_history = $activation_history->getVersionHistory(); |
|
34 | + // if $version_history does NOT exist, then this is a completely NEW install |
|
35 | + if (empty($version_history)) { |
|
36 | + return $this->newActivation($activation_history); |
|
37 | + } |
|
38 | + // NOT a new install, so check for a version change |
|
39 | + $version_change = $this->versionChange($activation_history); |
|
40 | + if ($version_change !== 0) { |
|
41 | + return $this->upgradeOrDowngrade($activation_history, $version_change); |
|
42 | + } |
|
43 | + // we've seen this version before, but its not an upgrade or downgrade, so maybe a reactivation? |
|
44 | + if ($activation_history->getActivationIndicator()) { |
|
45 | + return $this->reactivation($activation_history); |
|
46 | + } |
|
47 | + // not an activation. just a normal request |
|
48 | + return new ActivationType( |
|
49 | + ActivationType::NOT_ACTIVATION, |
|
50 | + $this->detectMajorVersionChange($activation_history) |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * @param ActivationHistory $activation_history |
|
57 | - * @return ActivationType |
|
58 | - * @throws InvalidArgumentException |
|
59 | - */ |
|
60 | - protected function newActivation(ActivationHistory $activation_history): ActivationType |
|
61 | - { |
|
62 | - $activation_type = new ActivationType( |
|
63 | - ActivationType::NEW_ACTIVATION, |
|
64 | - $this->detectMajorVersionChange($activation_history) |
|
65 | - ); |
|
66 | - $activation_history->deleteActivationIndicator(); |
|
67 | - return $activation_type; |
|
68 | - } |
|
55 | + /** |
|
56 | + * @param ActivationHistory $activation_history |
|
57 | + * @return ActivationType |
|
58 | + * @throws InvalidArgumentException |
|
59 | + */ |
|
60 | + protected function newActivation(ActivationHistory $activation_history): ActivationType |
|
61 | + { |
|
62 | + $activation_type = new ActivationType( |
|
63 | + ActivationType::NEW_ACTIVATION, |
|
64 | + $this->detectMajorVersionChange($activation_history) |
|
65 | + ); |
|
66 | + $activation_history->deleteActivationIndicator(); |
|
67 | + return $activation_type; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | |
71 | - /** |
|
72 | - * @param ActivationHistory $activation_history |
|
73 | - * @param int $version_change |
|
74 | - * @return ActivationType |
|
75 | - * @throws InvalidArgumentException |
|
76 | - */ |
|
77 | - protected function upgradeOrDowngrade(ActivationHistory $activation_history, int $version_change): ActivationType |
|
78 | - { |
|
79 | - // version change indicates an upgrade or downgrade |
|
80 | - $activation_type = new ActivationType( |
|
81 | - $version_change === 1 |
|
82 | - ? ActivationType::UPGRADE |
|
83 | - : ActivationType::DOWNGRADE, |
|
84 | - $this->detectMajorVersionChange($activation_history) |
|
85 | - ); |
|
86 | - $activation_history->deleteActivationIndicator(); |
|
87 | - return $activation_type; |
|
88 | - } |
|
71 | + /** |
|
72 | + * @param ActivationHistory $activation_history |
|
73 | + * @param int $version_change |
|
74 | + * @return ActivationType |
|
75 | + * @throws InvalidArgumentException |
|
76 | + */ |
|
77 | + protected function upgradeOrDowngrade(ActivationHistory $activation_history, int $version_change): ActivationType |
|
78 | + { |
|
79 | + // version change indicates an upgrade or downgrade |
|
80 | + $activation_type = new ActivationType( |
|
81 | + $version_change === 1 |
|
82 | + ? ActivationType::UPGRADE |
|
83 | + : ActivationType::DOWNGRADE, |
|
84 | + $this->detectMajorVersionChange($activation_history) |
|
85 | + ); |
|
86 | + $activation_history->deleteActivationIndicator(); |
|
87 | + return $activation_type; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * @param ActivationHistory $activation_history |
|
93 | - * @return ActivationType |
|
94 | - * @throws InvalidArgumentException |
|
95 | - */ |
|
96 | - protected function reactivation(ActivationHistory $activation_history): ActivationType |
|
97 | - { |
|
98 | - // it's an activation. must be a reactivation |
|
99 | - $activation_type = new ActivationType( |
|
100 | - ActivationType::REACTIVATION, |
|
101 | - $this->detectMajorVersionChange($activation_history) |
|
102 | - ); |
|
103 | - $activation_history->deleteActivationIndicator(); |
|
104 | - return $activation_type; |
|
105 | - } |
|
91 | + /** |
|
92 | + * @param ActivationHistory $activation_history |
|
93 | + * @return ActivationType |
|
94 | + * @throws InvalidArgumentException |
|
95 | + */ |
|
96 | + protected function reactivation(ActivationHistory $activation_history): ActivationType |
|
97 | + { |
|
98 | + // it's an activation. must be a reactivation |
|
99 | + $activation_type = new ActivationType( |
|
100 | + ActivationType::REACTIVATION, |
|
101 | + $this->detectMajorVersionChange($activation_history) |
|
102 | + ); |
|
103 | + $activation_history->deleteActivationIndicator(); |
|
104 | + return $activation_type; |
|
105 | + } |
|
106 | 106 | |
107 | 107 | |
108 | - /** |
|
109 | - * Detects if the current version is higher or lower than the most recent version in the $activation_history. |
|
110 | - * Returns results of version_compare() as follows: |
|
111 | - * -1 if current version is LOWER (downgrade); |
|
112 | - * 0 if current version MATCHES (reactivation or normal request); |
|
113 | - * 1 if current version is HIGHER (upgrade) ; |
|
114 | - * |
|
115 | - * @param ActivationHistory $activation_history |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - protected function versionChange(ActivationHistory $activation_history): int |
|
119 | - { |
|
120 | - return version_compare( |
|
121 | - $activation_history->getCurrentVersion(), |
|
122 | - $activation_history->getMostRecentActiveVersion() |
|
123 | - ); |
|
124 | - } |
|
108 | + /** |
|
109 | + * Detects if the current version is higher or lower than the most recent version in the $activation_history. |
|
110 | + * Returns results of version_compare() as follows: |
|
111 | + * -1 if current version is LOWER (downgrade); |
|
112 | + * 0 if current version MATCHES (reactivation or normal request); |
|
113 | + * 1 if current version is HIGHER (upgrade) ; |
|
114 | + * |
|
115 | + * @param ActivationHistory $activation_history |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + protected function versionChange(ActivationHistory $activation_history): int |
|
119 | + { |
|
120 | + return version_compare( |
|
121 | + $activation_history->getCurrentVersion(), |
|
122 | + $activation_history->getMostRecentActiveVersion() |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | |
126 | 126 | |
127 | - /** |
|
128 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
129 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
130 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
131 | - * |
|
132 | - * @param ActivationHistory $activation_history |
|
133 | - * @return bool |
|
134 | - */ |
|
135 | - protected function detectMajorVersionChange(ActivationHistory $activation_history): bool |
|
136 | - { |
|
137 | - $previous_version = $activation_history->getMostRecentActiveVersion(); |
|
138 | - $previous_version_parts = explode('.', $previous_version); |
|
139 | - $current_version_parts = explode('.', $activation_history->getCurrentVersion()); |
|
140 | - return isset( |
|
141 | - $previous_version_parts[0], |
|
142 | - $previous_version_parts[1], |
|
143 | - $current_version_parts[0], |
|
144 | - $current_version_parts[1] |
|
145 | - ) |
|
146 | - && ( |
|
147 | - $previous_version_parts[0] !== $current_version_parts[0] |
|
148 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
149 | - ); |
|
150 | - } |
|
127 | + /** |
|
128 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
129 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
130 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
131 | + * |
|
132 | + * @param ActivationHistory $activation_history |
|
133 | + * @return bool |
|
134 | + */ |
|
135 | + protected function detectMajorVersionChange(ActivationHistory $activation_history): bool |
|
136 | + { |
|
137 | + $previous_version = $activation_history->getMostRecentActiveVersion(); |
|
138 | + $previous_version_parts = explode('.', $previous_version); |
|
139 | + $current_version_parts = explode('.', $activation_history->getCurrentVersion()); |
|
140 | + return isset( |
|
141 | + $previous_version_parts[0], |
|
142 | + $previous_version_parts[1], |
|
143 | + $current_version_parts[0], |
|
144 | + $current_version_parts[1] |
|
145 | + ) |
|
146 | + && ( |
|
147 | + $previous_version_parts[0] !== $current_version_parts[0] |
|
148 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
149 | + ); |
|
150 | + } |
|
151 | 151 | } |
@@ -15,128 +15,128 @@ |
||
15 | 15 | */ |
16 | 16 | class ActivationType |
17 | 17 | { |
18 | - /** |
|
19 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
20 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
21 | - */ |
|
22 | - const NOT_ACTIVATION = 0; |
|
23 | - |
|
24 | - /** |
|
25 | - * Indicates this is a brand new installation of EE so we should install |
|
26 | - * tables and default data etc |
|
27 | - */ |
|
28 | - const NEW_ACTIVATION = 1; |
|
29 | - |
|
30 | - /** |
|
31 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
32 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
33 | - * and that default data is setup too |
|
34 | - */ |
|
35 | - const REACTIVATION = 2; |
|
36 | - |
|
37 | - /** |
|
38 | - * indicates that EE has been upgraded since its previous request. |
|
39 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
40 | - */ |
|
41 | - const UPGRADE = 3; |
|
42 | - |
|
43 | - /** |
|
44 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
45 | - */ |
|
46 | - const DOWNGRADE = 4; |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Stores which type of request this is, options being one of the constants above. |
|
51 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
52 | - * |
|
53 | - * @var int $activation_type |
|
54 | - */ |
|
55 | - private $activation_type; |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
60 | - * |
|
61 | - * @var boolean |
|
62 | - */ |
|
63 | - private $major_version_change; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * ActivationType constructor. |
|
68 | - * |
|
69 | - * @param int $activation_type |
|
70 | - * @param bool $major_version_change |
|
71 | - * @throws InvalidArgumentException |
|
72 | - */ |
|
73 | - public function __construct(int $activation_type = 0, bool $major_version_change = false) |
|
74 | - { |
|
75 | - $this->setActivationType($activation_type); |
|
76 | - $this->setMajorVersionChange($major_version_change); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @return array |
|
82 | - */ |
|
83 | - public function validActivationTypes(): array |
|
84 | - { |
|
85 | - return [ |
|
86 | - ActivationType::NOT_ACTIVATION, |
|
87 | - ActivationType::NEW_ACTIVATION, |
|
88 | - ActivationType::REACTIVATION, |
|
89 | - ActivationType::UPGRADE, |
|
90 | - ActivationType::DOWNGRADE, |
|
91 | - ]; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @return int |
|
97 | - */ |
|
98 | - public function getActivationType(): int |
|
99 | - { |
|
100 | - return $this->activation_type; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * @param int $request_type |
|
106 | - * @throws InvalidArgumentException |
|
107 | - */ |
|
108 | - public function setActivationType(int $request_type) |
|
109 | - { |
|
110 | - if (! in_array($request_type, $this->validActivationTypes(), true)) { |
|
111 | - throw new InvalidArgumentException( |
|
112 | - sprintf( |
|
113 | - esc_html__( |
|
114 | - 'The supplied value (%1$s) for the request type is invalid. Please use one of the constants on "%2$s"', |
|
115 | - 'event_espresso' |
|
116 | - ), |
|
117 | - $request_type, |
|
118 | - get_class($this) |
|
119 | - ) |
|
120 | - ); |
|
121 | - } |
|
122 | - $this->activation_type = $request_type; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @return bool |
|
128 | - */ |
|
129 | - public function isMajorVersionChange(): bool |
|
130 | - { |
|
131 | - return $this->major_version_change; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param bool $major_version_change |
|
137 | - */ |
|
138 | - public function setMajorVersionChange(bool $major_version_change) |
|
139 | - { |
|
140 | - $this->major_version_change = filter_var($major_version_change, FILTER_VALIDATE_BOOLEAN); |
|
141 | - } |
|
18 | + /** |
|
19 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
20 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
21 | + */ |
|
22 | + const NOT_ACTIVATION = 0; |
|
23 | + |
|
24 | + /** |
|
25 | + * Indicates this is a brand new installation of EE so we should install |
|
26 | + * tables and default data etc |
|
27 | + */ |
|
28 | + const NEW_ACTIVATION = 1; |
|
29 | + |
|
30 | + /** |
|
31 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
32 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
33 | + * and that default data is setup too |
|
34 | + */ |
|
35 | + const REACTIVATION = 2; |
|
36 | + |
|
37 | + /** |
|
38 | + * indicates that EE has been upgraded since its previous request. |
|
39 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
40 | + */ |
|
41 | + const UPGRADE = 3; |
|
42 | + |
|
43 | + /** |
|
44 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
45 | + */ |
|
46 | + const DOWNGRADE = 4; |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Stores which type of request this is, options being one of the constants above. |
|
51 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
52 | + * |
|
53 | + * @var int $activation_type |
|
54 | + */ |
|
55 | + private $activation_type; |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
60 | + * |
|
61 | + * @var boolean |
|
62 | + */ |
|
63 | + private $major_version_change; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * ActivationType constructor. |
|
68 | + * |
|
69 | + * @param int $activation_type |
|
70 | + * @param bool $major_version_change |
|
71 | + * @throws InvalidArgumentException |
|
72 | + */ |
|
73 | + public function __construct(int $activation_type = 0, bool $major_version_change = false) |
|
74 | + { |
|
75 | + $this->setActivationType($activation_type); |
|
76 | + $this->setMajorVersionChange($major_version_change); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @return array |
|
82 | + */ |
|
83 | + public function validActivationTypes(): array |
|
84 | + { |
|
85 | + return [ |
|
86 | + ActivationType::NOT_ACTIVATION, |
|
87 | + ActivationType::NEW_ACTIVATION, |
|
88 | + ActivationType::REACTIVATION, |
|
89 | + ActivationType::UPGRADE, |
|
90 | + ActivationType::DOWNGRADE, |
|
91 | + ]; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @return int |
|
97 | + */ |
|
98 | + public function getActivationType(): int |
|
99 | + { |
|
100 | + return $this->activation_type; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * @param int $request_type |
|
106 | + * @throws InvalidArgumentException |
|
107 | + */ |
|
108 | + public function setActivationType(int $request_type) |
|
109 | + { |
|
110 | + if (! in_array($request_type, $this->validActivationTypes(), true)) { |
|
111 | + throw new InvalidArgumentException( |
|
112 | + sprintf( |
|
113 | + esc_html__( |
|
114 | + 'The supplied value (%1$s) for the request type is invalid. Please use one of the constants on "%2$s"', |
|
115 | + 'event_espresso' |
|
116 | + ), |
|
117 | + $request_type, |
|
118 | + get_class($this) |
|
119 | + ) |
|
120 | + ); |
|
121 | + } |
|
122 | + $this->activation_type = $request_type; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @return bool |
|
128 | + */ |
|
129 | + public function isMajorVersionChange(): bool |
|
130 | + { |
|
131 | + return $this->major_version_change; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param bool $major_version_change |
|
137 | + */ |
|
138 | + public function setMajorVersionChange(bool $major_version_change) |
|
139 | + { |
|
140 | + $this->major_version_change = filter_var($major_version_change, FILTER_VALIDATE_BOOLEAN); |
|
141 | + } |
|
142 | 142 | } |
@@ -107,7 +107,7 @@ |
||
107 | 107 | */ |
108 | 108 | public function setActivationType(int $request_type) |
109 | 109 | { |
110 | - if (! in_array($request_type, $this->validActivationTypes(), true)) { |
|
110 | + if ( ! in_array($request_type, $this->validActivationTypes(), true)) { |
|
111 | 111 | throw new InvalidArgumentException( |
112 | 112 | sprintf( |
113 | 113 | esc_html__( |
@@ -16,43 +16,43 @@ |
||
16 | 16 | class EE_Soft_Delete_Where_Conditions extends EE_Default_Where_Conditions |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * Gets the where default where conditions for a custom post type model |
|
21 | - * |
|
22 | - * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
|
23 | - * @throws EE_Error |
|
24 | - */ |
|
25 | - protected function _get_default_where_conditions(): array |
|
26 | - { |
|
27 | - $trashed_field_name = $this->deleted_field_name(); |
|
28 | - return [ |
|
29 | - $trashed_field_name => false, |
|
30 | - ]; |
|
31 | - } |
|
19 | + /** |
|
20 | + * Gets the where default where conditions for a custom post type model |
|
21 | + * |
|
22 | + * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions) |
|
23 | + * @throws EE_Error |
|
24 | + */ |
|
25 | + protected function _get_default_where_conditions(): array |
|
26 | + { |
|
27 | + $trashed_field_name = $this->deleted_field_name(); |
|
28 | + return [ |
|
29 | + $trashed_field_name => false, |
|
30 | + ]; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Searches for field on the model of type 'deleted_flag', |
|
36 | - * and returns its name if found, |
|
37 | - * |
|
38 | - * @return string |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - private function deleted_field_name(): string |
|
42 | - { |
|
43 | - $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
44 | - if ($field) { |
|
45 | - return $field->get_name(); |
|
46 | - } |
|
47 | - throw new EE_Error( |
|
48 | - sprintf( |
|
49 | - __( |
|
50 | - 'We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
51 | - 'event_espresso' |
|
52 | - ), |
|
53 | - get_class($this), |
|
54 | - get_class($this) |
|
55 | - ) |
|
56 | - ); |
|
57 | - } |
|
34 | + /** |
|
35 | + * Searches for field on the model of type 'deleted_flag', |
|
36 | + * and returns its name if found, |
|
37 | + * |
|
38 | + * @return string |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + private function deleted_field_name(): string |
|
42 | + { |
|
43 | + $field = $this->_model->get_a_field_of_type('EE_Trashed_Flag_Field'); |
|
44 | + if ($field) { |
|
45 | + return $field->get_name(); |
|
46 | + } |
|
47 | + throw new EE_Error( |
|
48 | + sprintf( |
|
49 | + __( |
|
50 | + 'We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', |
|
51 | + 'event_espresso' |
|
52 | + ), |
|
53 | + get_class($this), |
|
54 | + get_class($this) |
|
55 | + ) |
|
56 | + ); |
|
57 | + } |
|
58 | 58 | } |