@@ -26,124 +26,124 @@ |
||
26 | 26 | class Checkin extends Base |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @param WP_REST_Request $request |
|
31 | - * @param string $version |
|
32 | - * @return WP_Error|WP_REST_Response |
|
33 | - */ |
|
34 | - public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
35 | - { |
|
36 | - $controller = new Checkin(); |
|
37 | - return $controller->createCheckinCheckoutObject($request, $version); |
|
38 | - } |
|
29 | + /** |
|
30 | + * @param WP_REST_Request $request |
|
31 | + * @param string $version |
|
32 | + * @return WP_Error|WP_REST_Response |
|
33 | + */ |
|
34 | + public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
35 | + { |
|
36 | + $controller = new Checkin(); |
|
37 | + return $controller->createCheckinCheckoutObject($request, $version); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Toggles whether the user is checked in or not. |
|
43 | - * |
|
44 | - * @param WP_REST_Request $request |
|
45 | - * @param string $version |
|
46 | - * @return WP_Error|WP_REST_Response |
|
47 | - */ |
|
48 | - protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
49 | - { |
|
50 | - $reg_id = $request->get_param('REG_ID'); |
|
51 | - $dtt_id = $request->get_param('DTT_ID'); |
|
52 | - $force = $request->get_param('force'); |
|
53 | - if ($force == 'true') { |
|
54 | - $force = true; |
|
55 | - } else { |
|
56 | - $force = false; |
|
57 | - } |
|
58 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
59 | - if (! $reg instanceof EE_Registration) { |
|
60 | - return $this->sendResponse( |
|
61 | - new WP_Error( |
|
62 | - 'rest_registration_toggle_checkin_invalid_id', |
|
63 | - sprintf( |
|
64 | - __( |
|
65 | - 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - $reg_id |
|
69 | - ), |
|
70 | - array('status' => 422) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | - return $this->sendResponse( |
|
76 | - new WP_Error( |
|
77 | - 'rest_user_cannot_toggle_checkin', |
|
78 | - sprintf( |
|
79 | - __('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
80 | - $reg_id |
|
81 | - ), |
|
82 | - array('status' => 403) |
|
83 | - ) |
|
84 | - ); |
|
85 | - } |
|
86 | - $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
87 | - if ($success === false) { |
|
88 | - // check if we know they can't check in because they're not approved and we aren't forcing |
|
89 | - if (! $reg->is_approved() && ! $force) { |
|
90 | - // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
91 | - return $this->sendResponse( |
|
92 | - new WP_Error( |
|
93 | - 'rest_toggle_checkin_failed', |
|
94 | - __( |
|
95 | - // @codingStandardsIgnoreStart |
|
96 | - 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
97 | - // @codingStandardsIgnoreEnd |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - return $this->sendResponse( |
|
104 | - new WP_Error( |
|
105 | - 'rest_toggle_checkin_failed_not_forceable', |
|
106 | - __('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
110 | - $checkin = EEM_Checkin::instance()->get_one( |
|
111 | - array( |
|
112 | - array( |
|
113 | - 'REG_ID' => $reg_id, |
|
114 | - 'DTT_ID' => $dtt_id, |
|
115 | - ), |
|
116 | - 'order_by' => array( |
|
117 | - 'CHK_timestamp' => 'DESC', |
|
118 | - ), |
|
119 | - ) |
|
120 | - ); |
|
121 | - if (! $checkin instanceof EE_Checkin) { |
|
122 | - return $this->sendResponse( |
|
123 | - new WP_Error( |
|
124 | - 'rest_toggle_checkin_error', |
|
125 | - sprintf( |
|
126 | - __( |
|
127 | - // @codingStandardsIgnoreStart |
|
128 | - 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
129 | - // @codingStandardsIgnoreEnd |
|
130 | - 'event_espresso' |
|
131 | - ), |
|
132 | - $reg_id, |
|
133 | - $dtt_id |
|
134 | - ) |
|
135 | - ) |
|
136 | - ); |
|
137 | - } |
|
138 | - $get_request = new WP_REST_Request( |
|
139 | - 'GET', |
|
140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
141 | - ); |
|
142 | - $get_request->set_url_params( |
|
143 | - array( |
|
144 | - 'id' => $checkin->ID(), |
|
145 | - ) |
|
146 | - ); |
|
147 | - return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
148 | - } |
|
41 | + /** |
|
42 | + * Toggles whether the user is checked in or not. |
|
43 | + * |
|
44 | + * @param WP_REST_Request $request |
|
45 | + * @param string $version |
|
46 | + * @return WP_Error|WP_REST_Response |
|
47 | + */ |
|
48 | + protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
49 | + { |
|
50 | + $reg_id = $request->get_param('REG_ID'); |
|
51 | + $dtt_id = $request->get_param('DTT_ID'); |
|
52 | + $force = $request->get_param('force'); |
|
53 | + if ($force == 'true') { |
|
54 | + $force = true; |
|
55 | + } else { |
|
56 | + $force = false; |
|
57 | + } |
|
58 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
59 | + if (! $reg instanceof EE_Registration) { |
|
60 | + return $this->sendResponse( |
|
61 | + new WP_Error( |
|
62 | + 'rest_registration_toggle_checkin_invalid_id', |
|
63 | + sprintf( |
|
64 | + __( |
|
65 | + 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + $reg_id |
|
69 | + ), |
|
70 | + array('status' => 422) |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | + if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | + return $this->sendResponse( |
|
76 | + new WP_Error( |
|
77 | + 'rest_user_cannot_toggle_checkin', |
|
78 | + sprintf( |
|
79 | + __('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
80 | + $reg_id |
|
81 | + ), |
|
82 | + array('status' => 403) |
|
83 | + ) |
|
84 | + ); |
|
85 | + } |
|
86 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
87 | + if ($success === false) { |
|
88 | + // check if we know they can't check in because they're not approved and we aren't forcing |
|
89 | + if (! $reg->is_approved() && ! $force) { |
|
90 | + // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
91 | + return $this->sendResponse( |
|
92 | + new WP_Error( |
|
93 | + 'rest_toggle_checkin_failed', |
|
94 | + __( |
|
95 | + // @codingStandardsIgnoreStart |
|
96 | + 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
97 | + // @codingStandardsIgnoreEnd |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + return $this->sendResponse( |
|
104 | + new WP_Error( |
|
105 | + 'rest_toggle_checkin_failed_not_forceable', |
|
106 | + __('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | + $checkin = EEM_Checkin::instance()->get_one( |
|
111 | + array( |
|
112 | + array( |
|
113 | + 'REG_ID' => $reg_id, |
|
114 | + 'DTT_ID' => $dtt_id, |
|
115 | + ), |
|
116 | + 'order_by' => array( |
|
117 | + 'CHK_timestamp' => 'DESC', |
|
118 | + ), |
|
119 | + ) |
|
120 | + ); |
|
121 | + if (! $checkin instanceof EE_Checkin) { |
|
122 | + return $this->sendResponse( |
|
123 | + new WP_Error( |
|
124 | + 'rest_toggle_checkin_error', |
|
125 | + sprintf( |
|
126 | + __( |
|
127 | + // @codingStandardsIgnoreStart |
|
128 | + 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
129 | + // @codingStandardsIgnoreEnd |
|
130 | + 'event_espresso' |
|
131 | + ), |
|
132 | + $reg_id, |
|
133 | + $dtt_id |
|
134 | + ) |
|
135 | + ) |
|
136 | + ); |
|
137 | + } |
|
138 | + $get_request = new WP_REST_Request( |
|
139 | + 'GET', |
|
140 | + '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
141 | + ); |
|
142 | + $get_request->set_url_params( |
|
143 | + array( |
|
144 | + 'id' => $checkin->ID(), |
|
145 | + ) |
|
146 | + ); |
|
147 | + return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
148 | + } |
|
149 | 149 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $force = false; |
57 | 57 | } |
58 | 58 | $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
59 | - if (! $reg instanceof EE_Registration) { |
|
59 | + if ( ! $reg instanceof EE_Registration) { |
|
60 | 60 | return $this->sendResponse( |
61 | 61 | new WP_Error( |
62 | 62 | 'rest_registration_toggle_checkin_invalid_id', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | } |
74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
74 | + if ( ! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | 75 | return $this->sendResponse( |
76 | 76 | new WP_Error( |
77 | 77 | 'rest_user_cannot_toggle_checkin', |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
87 | 87 | if ($success === false) { |
88 | 88 | // check if we know they can't check in because they're not approved and we aren't forcing |
89 | - if (! $reg->is_approved() && ! $force) { |
|
89 | + if ( ! $reg->is_approved() && ! $force) { |
|
90 | 90 | // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
91 | 91 | return $this->sendResponse( |
92 | 92 | new WP_Error( |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ), |
119 | 119 | ) |
120 | 120 | ); |
121 | - if (! $checkin instanceof EE_Checkin) { |
|
121 | + if ( ! $checkin instanceof EE_Checkin) { |
|
122 | 122 | return $this->sendResponse( |
123 | 123 | new WP_Error( |
124 | 124 | 'rest_toggle_checkin_error', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | $get_request = new WP_REST_Request( |
139 | 139 | 'GET', |
140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
140 | + '/'.EED_Core_Rest_Api::ee_api_namespace.'v'.$version.'/checkins/'.$checkin->ID() |
|
141 | 141 | ); |
142 | 142 | $get_request->set_url_params( |
143 | 143 | array( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function __construct(\EEHI_File $file_helper = null) |
34 | 34 | { |
35 | - if (! $file_helper) { |
|
35 | + if ( ! $file_helper) { |
|
36 | 36 | $this->_file_helper = new \EEH_File(); |
37 | 37 | } |
38 | 38 | } |
@@ -53,28 +53,28 @@ discard block |
||
53 | 53 | try { |
54 | 54 | $base_folder = $this->get_base_folder(); |
55 | 55 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
56 | - $base_folder . JobHandlerFile::temp_folder_name |
|
56 | + $base_folder.JobHandlerFile::temp_folder_name |
|
57 | 57 | ); |
58 | 58 | if ($success) { |
59 | 59 | $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
60 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
60 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id |
|
61 | 61 | ); |
62 | 62 | } |
63 | 63 | if ($success) { |
64 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
64 | + $filepath = $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.$filename; |
|
65 | 65 | $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
66 | 66 | } |
67 | 67 | // let's add the .htaccess file so safari will open the file properly |
68 | 68 | if ($success) { |
69 | 69 | $extension = \EEH_File::get_file_extension($filepath); |
70 | 70 | \EEH_File::write_to_file( |
71 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
72 | - 'AddType ' . $filetype . ' ' . $extension, |
|
71 | + $base_folder.JobHandlerFile::temp_folder_name.DS.$job_id.DS.'.htaccess', |
|
72 | + 'AddType '.$filetype.' '.$extension, |
|
73 | 73 | '.htaccess' |
74 | 74 | ); |
75 | 75 | } |
76 | 76 | // those methods normally fail with an exception, but if not, let's do it |
77 | - if (! $success) { |
|
77 | + if ( ! $success) { |
|
78 | 78 | throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
79 | 79 | } |
80 | 80 | } catch (\EE_Error $e) { |
@@ -16,111 +16,111 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class JobHandlerFile extends JobHandler |
18 | 18 | { |
19 | - // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
20 | - const temp_folder_name = 'batch_temp_folder'; |
|
19 | + // phpcs:disable Generic.NamingConventions.UpperCaseConstantName.ClassConstantNotUpperCase |
|
20 | + const temp_folder_name = 'batch_temp_folder'; |
|
21 | 21 | |
22 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
23 | - /** |
|
24 | - * @var \EEHI_File |
|
25 | - */ |
|
26 | - protected $_file_helper = null; |
|
22 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
23 | + /** |
|
24 | + * @var \EEHI_File |
|
25 | + */ |
|
26 | + protected $_file_helper = null; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * JobHandlerFile constructor. |
|
31 | - * |
|
32 | - * @param \EEHI_File|null $file_helper |
|
33 | - */ |
|
34 | - public function __construct(\EEHI_File $file_helper = null) |
|
35 | - { |
|
36 | - if (! $file_helper) { |
|
37 | - $this->_file_helper = new \EEH_File(); |
|
38 | - } |
|
39 | - } |
|
29 | + /** |
|
30 | + * JobHandlerFile constructor. |
|
31 | + * |
|
32 | + * @param \EEHI_File|null $file_helper |
|
33 | + */ |
|
34 | + public function __construct(\EEHI_File $file_helper = null) |
|
35 | + { |
|
36 | + if (! $file_helper) { |
|
37 | + $this->_file_helper = new \EEH_File(); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | - /** |
|
43 | - * Creates a file |
|
44 | - * |
|
45 | - * @param string $job_id |
|
46 | - * @param string $filename |
|
47 | - * @param string $filetype |
|
48 | - * @return string |
|
49 | - * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
50 | - */ |
|
51 | - public function create_file_from_job_with_name($job_id, $filename, $filetype = 'application/ms-excel') |
|
52 | - { |
|
53 | - $filepath = ''; |
|
54 | - try { |
|
55 | - $base_folder = $this->get_base_folder(); |
|
56 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
57 | - $base_folder . JobHandlerFile::temp_folder_name |
|
58 | - ); |
|
59 | - if ($success) { |
|
60 | - $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
61 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
62 | - ); |
|
63 | - } |
|
64 | - if ($success) { |
|
65 | - $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
66 | - $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
67 | - } |
|
68 | - // let's add the .htaccess file so safari will open the file properly |
|
69 | - if ($success) { |
|
70 | - $extension = \EEH_File::get_file_extension($filepath); |
|
71 | - \EEH_File::write_to_file( |
|
72 | - $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
73 | - 'AddType ' . $filetype . ' ' . $extension, |
|
74 | - '.htaccess' |
|
75 | - ); |
|
76 | - } |
|
77 | - // those methods normally fail with an exception, but if not, let's do it |
|
78 | - if (! $success) { |
|
79 | - throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
80 | - } |
|
81 | - } catch (\EE_Error $e) { |
|
82 | - throw new BatchRequestException( |
|
83 | - sprintf( |
|
84 | - __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
85 | - $job_id, |
|
86 | - $e->getMessage() |
|
87 | - ), |
|
88 | - 500, |
|
89 | - $e |
|
90 | - ); |
|
91 | - } |
|
92 | - return $filepath; |
|
93 | - } |
|
41 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | + /** |
|
43 | + * Creates a file |
|
44 | + * |
|
45 | + * @param string $job_id |
|
46 | + * @param string $filename |
|
47 | + * @param string $filetype |
|
48 | + * @return string |
|
49 | + * @throws \EventEspressoBatchRequest\Helpers\BatchRequestException |
|
50 | + */ |
|
51 | + public function create_file_from_job_with_name($job_id, $filename, $filetype = 'application/ms-excel') |
|
52 | + { |
|
53 | + $filepath = ''; |
|
54 | + try { |
|
55 | + $base_folder = $this->get_base_folder(); |
|
56 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
57 | + $base_folder . JobHandlerFile::temp_folder_name |
|
58 | + ); |
|
59 | + if ($success) { |
|
60 | + $success = $this->_file_helper->ensure_folder_exists_and_is_writable( |
|
61 | + $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id |
|
62 | + ); |
|
63 | + } |
|
64 | + if ($success) { |
|
65 | + $filepath = $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . $filename; |
|
66 | + $success = $this->_file_helper->ensure_file_exists_and_is_writable($filepath); |
|
67 | + } |
|
68 | + // let's add the .htaccess file so safari will open the file properly |
|
69 | + if ($success) { |
|
70 | + $extension = \EEH_File::get_file_extension($filepath); |
|
71 | + \EEH_File::write_to_file( |
|
72 | + $base_folder . JobHandlerFile::temp_folder_name . DS . $job_id . DS . '.htaccess', |
|
73 | + 'AddType ' . $filetype . ' ' . $extension, |
|
74 | + '.htaccess' |
|
75 | + ); |
|
76 | + } |
|
77 | + // those methods normally fail with an exception, but if not, let's do it |
|
78 | + if (! $success) { |
|
79 | + throw new \EE_Error(__('Could not create temporary file, an unknown error occurred', 'event_espresso')); |
|
80 | + } |
|
81 | + } catch (\EE_Error $e) { |
|
82 | + throw new BatchRequestException( |
|
83 | + sprintf( |
|
84 | + __('Could not create temporary file for job %1$s, because: %2$s ', 'event_espresso'), |
|
85 | + $job_id, |
|
86 | + $e->getMessage() |
|
87 | + ), |
|
88 | + 500, |
|
89 | + $e |
|
90 | + ); |
|
91 | + } |
|
92 | + return $filepath; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Gets the URL to download the file |
|
97 | - * |
|
98 | - * @param string $filepath |
|
99 | - * @return string url to file |
|
100 | - */ |
|
101 | - public function get_url_to_file($filepath) |
|
102 | - { |
|
103 | - return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
104 | - } |
|
95 | + /** |
|
96 | + * Gets the URL to download the file |
|
97 | + * |
|
98 | + * @param string $filepath |
|
99 | + * @return string url to file |
|
100 | + */ |
|
101 | + public function get_url_to_file($filepath) |
|
102 | + { |
|
103 | + return str_replace($this->get_base_folder(), $this->get_base_url(), $filepath); |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Gets the folder which will contain the "batch_temp_folder" |
|
108 | - * |
|
109 | - * @return string |
|
110 | - */ |
|
111 | - public function get_base_folder() |
|
112 | - { |
|
113 | - return apply_filters( |
|
114 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
115 | - EVENT_ESPRESSO_UPLOAD_DIR |
|
116 | - ); |
|
117 | - } |
|
106 | + /** |
|
107 | + * Gets the folder which will contain the "batch_temp_folder" |
|
108 | + * |
|
109 | + * @return string |
|
110 | + */ |
|
111 | + public function get_base_folder() |
|
112 | + { |
|
113 | + return apply_filters( |
|
114 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_folder', |
|
115 | + EVENT_ESPRESSO_UPLOAD_DIR |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | |
119 | - public function get_base_url() |
|
120 | - { |
|
121 | - return apply_filters( |
|
122 | - 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
123 | - EVENT_ESPRESSO_UPLOAD_URL |
|
124 | - ); |
|
125 | - } |
|
119 | + public function get_base_url() |
|
120 | + { |
|
121 | + return apply_filters( |
|
122 | + 'FHEE__EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile__get_base_url', |
|
123 | + EVENT_ESPRESSO_UPLOAD_URL |
|
124 | + ); |
|
125 | + } |
|
126 | 126 | } |
@@ -13,5 +13,5 @@ |
||
13 | 13 | */ |
14 | 14 | abstract class JobHandler implements JobHandlerInterface |
15 | 15 | { |
16 | - // so far no common methods or properties |
|
16 | + // so far no common methods or properties |
|
17 | 17 | } |
@@ -14,5 +14,5 @@ |
||
14 | 14 | */ |
15 | 15 | class BatchRequestException extends \Exception |
16 | 16 | { |
17 | - // so far the same as exception |
|
17 | + // so far the same as exception |
|
18 | 18 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
55 | 55 | $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
56 | 56 | $response = $obj->create_job($this->_job_parameters); |
57 | - if (! $response instanceof JobStepResponse) { |
|
57 | + if ( ! $response instanceof JobStepResponse) { |
|
58 | 58 | throw new BatchRequestException( |
59 | 59 | sprintf( |
60 | 60 | __( |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ); |
67 | 67 | } |
68 | 68 | $success = $this->_job_parameters->save(true); |
69 | - if (! $success) { |
|
69 | + if ( ! $success) { |
|
70 | 70 | throw new BatchRequestException( |
71 | 71 | sprintf( |
72 | 72 | __( |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
103 | 103 | // continue it |
104 | 104 | $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
105 | - if (! $response instanceof JobStepResponse) { |
|
105 | + if ( ! $response instanceof JobStepResponse) { |
|
106 | 106 | throw new BatchRequestException( |
107 | 107 | sprintf( |
108 | 108 | __( |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | */ |
132 | 132 | public function instantiate_batch_job_handler_from_classname($classname) |
133 | 133 | { |
134 | - if (! class_exists($classname)) { |
|
134 | + if ( ! class_exists($classname)) { |
|
135 | 135 | throw new BatchRequestException( |
136 | 136 | sprintf( |
137 | 137 | __( |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ); |
144 | 144 | } |
145 | 145 | $obj = new $classname; |
146 | - if (! $obj instanceof JobHandlerInterface) { |
|
146 | + if ( ! $obj instanceof JobHandlerInterface) { |
|
147 | 147 | throw new BatchRequestException( |
148 | 148 | sprintf( |
149 | 149 | __( |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
174 | 174 | // continue it |
175 | 175 | $response = $handler_obj->cleanup_job($job_parameters); |
176 | - if (! $response instanceof JobStepResponse) { |
|
176 | + if ( ! $response instanceof JobStepResponse) { |
|
177 | 177 | throw new BatchRequestException( |
178 | 178 | sprintf( |
179 | 179 | __( |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | */ |
204 | 204 | protected function _get_error_response(\Exception $exception, $method_name) |
205 | 205 | { |
206 | - if (! $this->_job_parameters instanceof JobParameters) { |
|
206 | + if ( ! $this->_job_parameters instanceof JobParameters) { |
|
207 | 207 | $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
208 | 208 | } |
209 | 209 | $this->_job_parameters->set_status(JobParameters::status_error); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | 'event_espresso' |
216 | 216 | ), |
217 | 217 | get_class($exception), |
218 | - 'BatchRunner::' . $method_name . '()', |
|
218 | + 'BatchRunner::'.$method_name.'()', |
|
219 | 219 | $exception->getMessage(), |
220 | 220 | $exception->getTraceAsString() |
221 | 221 | ) |
@@ -23,203 +23,203 @@ |
||
23 | 23 | */ |
24 | 24 | class BatchRequestProcessor |
25 | 25 | { |
26 | - // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
27 | - // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
28 | - /** |
|
29 | - * Current job's ID (if assigned) |
|
30 | - * |
|
31 | - * @var string|null |
|
32 | - */ |
|
33 | - protected $_job_id; |
|
26 | + // phpcs:disable PSR2.Classes.PropertyDeclaration.Underscore |
|
27 | + // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
|
28 | + /** |
|
29 | + * Current job's ID (if assigned) |
|
30 | + * |
|
31 | + * @var string|null |
|
32 | + */ |
|
33 | + protected $_job_id; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Current job's parameters |
|
37 | - * |
|
38 | - * @var JobParameters|null |
|
39 | - */ |
|
40 | - protected $_job_parameters; |
|
35 | + /** |
|
36 | + * Current job's parameters |
|
37 | + * |
|
38 | + * @var JobParameters|null |
|
39 | + */ |
|
40 | + protected $_job_parameters; |
|
41 | 41 | |
42 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | - /** |
|
44 | - * Creates a job for the specified batch handler class (which should be autoloaded) |
|
45 | - * and the specified request data |
|
46 | - * |
|
47 | - * @param string $batch_job_handler_class of an auto-loaded class implementing JobHandlerInterface |
|
48 | - * @param array $request_data to be used by the batch job handler |
|
49 | - * @return JobStepResponse |
|
50 | - */ |
|
51 | - public function create_job($batch_job_handler_class, $request_data) |
|
52 | - { |
|
53 | - try { |
|
54 | - $this->_job_id = wp_generate_password(15, false); |
|
55 | - $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
56 | - $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
57 | - $response = $obj->create_job($this->_job_parameters); |
|
58 | - if (! $response instanceof JobStepResponse) { |
|
59 | - throw new BatchRequestException( |
|
60 | - sprintf( |
|
61 | - __( |
|
62 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', |
|
63 | - 'event_espresso' |
|
64 | - ), |
|
65 | - wp_json_encode($request_data) |
|
66 | - ) |
|
67 | - ); |
|
68 | - } |
|
69 | - $success = $this->_job_parameters->save(true); |
|
70 | - if (! $success) { |
|
71 | - throw new BatchRequestException( |
|
72 | - sprintf( |
|
73 | - __( |
|
74 | - 'Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - $this->_job_id, |
|
78 | - wp_json_encode($request_data) |
|
79 | - ) |
|
80 | - ); |
|
81 | - } |
|
82 | - } catch (\Exception $e) { |
|
83 | - $response = $this->_get_error_response($e, 'create_job'); |
|
84 | - } |
|
85 | - return $response; |
|
86 | - } |
|
42 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | + /** |
|
44 | + * Creates a job for the specified batch handler class (which should be autoloaded) |
|
45 | + * and the specified request data |
|
46 | + * |
|
47 | + * @param string $batch_job_handler_class of an auto-loaded class implementing JobHandlerInterface |
|
48 | + * @param array $request_data to be used by the batch job handler |
|
49 | + * @return JobStepResponse |
|
50 | + */ |
|
51 | + public function create_job($batch_job_handler_class, $request_data) |
|
52 | + { |
|
53 | + try { |
|
54 | + $this->_job_id = wp_generate_password(15, false); |
|
55 | + $obj = $this->instantiate_batch_job_handler_from_classname($batch_job_handler_class); |
|
56 | + $this->_job_parameters = new JobParameters($this->_job_id, $batch_job_handler_class, $request_data); |
|
57 | + $response = $obj->create_job($this->_job_parameters); |
|
58 | + if (! $response instanceof JobStepResponse) { |
|
59 | + throw new BatchRequestException( |
|
60 | + sprintf( |
|
61 | + __( |
|
62 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when create_job was called with %1$s. It needs to return one or throw an Exception', |
|
63 | + 'event_espresso' |
|
64 | + ), |
|
65 | + wp_json_encode($request_data) |
|
66 | + ) |
|
67 | + ); |
|
68 | + } |
|
69 | + $success = $this->_job_parameters->save(true); |
|
70 | + if (! $success) { |
|
71 | + throw new BatchRequestException( |
|
72 | + sprintf( |
|
73 | + __( |
|
74 | + 'Could not save job %1$s to the Wordpress Options table. These were the arguments used: %2$s', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + $this->_job_id, |
|
78 | + wp_json_encode($request_data) |
|
79 | + ) |
|
80 | + ); |
|
81 | + } |
|
82 | + } catch (\Exception $e) { |
|
83 | + $response = $this->_get_error_response($e, 'create_job'); |
|
84 | + } |
|
85 | + return $response; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - /** |
|
90 | - * Retrieves the job's arguments |
|
91 | - * |
|
92 | - * @param string $job_id |
|
93 | - * @param int $batch_size |
|
94 | - * @return JobStepResponse |
|
95 | - */ |
|
96 | - public function continue_job($job_id, $batch_size = 50) |
|
97 | - { |
|
98 | - try { |
|
99 | - $this->_job_id = $job_id; |
|
100 | - $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
101 | - // get the corresponding WordPress option for the job |
|
102 | - $this->_job_parameters = JobParameters::load($this->_job_id); |
|
103 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
104 | - // continue it |
|
105 | - $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
106 | - if (! $response instanceof JobStepResponse) { |
|
107 | - throw new BatchRequestException( |
|
108 | - sprintf( |
|
109 | - __( |
|
110 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', |
|
111 | - 'event_espresso' |
|
112 | - ), |
|
113 | - $this->_job_id |
|
114 | - ) |
|
115 | - ); |
|
116 | - } |
|
117 | - $this->_job_parameters->save(); |
|
118 | - } catch (\Exception $e) { |
|
119 | - $response = $this->_get_error_response($e, 'continue_job'); |
|
120 | - } |
|
121 | - return $response; |
|
122 | - } |
|
89 | + /** |
|
90 | + * Retrieves the job's arguments |
|
91 | + * |
|
92 | + * @param string $job_id |
|
93 | + * @param int $batch_size |
|
94 | + * @return JobStepResponse |
|
95 | + */ |
|
96 | + public function continue_job($job_id, $batch_size = 50) |
|
97 | + { |
|
98 | + try { |
|
99 | + $this->_job_id = $job_id; |
|
100 | + $batch_size = defined('EE_BATCHRUNNER_BATCH_SIZE') ? EE_BATCHRUNNER_BATCH_SIZE : $batch_size; |
|
101 | + // get the corresponding WordPress option for the job |
|
102 | + $this->_job_parameters = JobParameters::load($this->_job_id); |
|
103 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($this->_job_parameters->classname()); |
|
104 | + // continue it |
|
105 | + $response = $handler_obj->continue_job($this->_job_parameters, $batch_size); |
|
106 | + if (! $response instanceof JobStepResponse) { |
|
107 | + throw new BatchRequestException( |
|
108 | + sprintf( |
|
109 | + __( |
|
110 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when continue_job was called with job %1$s. It needs to return one or throw an Exception', |
|
111 | + 'event_espresso' |
|
112 | + ), |
|
113 | + $this->_job_id |
|
114 | + ) |
|
115 | + ); |
|
116 | + } |
|
117 | + $this->_job_parameters->save(); |
|
118 | + } catch (\Exception $e) { |
|
119 | + $response = $this->_get_error_response($e, 'continue_job'); |
|
120 | + } |
|
121 | + return $response; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Instantiates an object of type $classname, which implements |
|
127 | - * JobHandlerInterface |
|
128 | - * |
|
129 | - * @param string $classname |
|
130 | - * @return JobHandlerInterface |
|
131 | - * @throws BatchRequestException |
|
132 | - */ |
|
133 | - public function instantiate_batch_job_handler_from_classname($classname) |
|
134 | - { |
|
135 | - if (! class_exists($classname)) { |
|
136 | - throw new BatchRequestException( |
|
137 | - sprintf( |
|
138 | - __( |
|
139 | - 'The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - $classname |
|
143 | - ) |
|
144 | - ); |
|
145 | - } |
|
146 | - $obj = new $classname; |
|
147 | - if (! $obj instanceof JobHandlerInterface) { |
|
148 | - throw new BatchRequestException( |
|
149 | - sprintf( |
|
150 | - __( |
|
151 | - 'The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', |
|
152 | - 'event_espresso' |
|
153 | - ), |
|
154 | - $classname |
|
155 | - ) |
|
156 | - ); |
|
157 | - } |
|
158 | - return $obj; |
|
159 | - } |
|
125 | + /** |
|
126 | + * Instantiates an object of type $classname, which implements |
|
127 | + * JobHandlerInterface |
|
128 | + * |
|
129 | + * @param string $classname |
|
130 | + * @return JobHandlerInterface |
|
131 | + * @throws BatchRequestException |
|
132 | + */ |
|
133 | + public function instantiate_batch_job_handler_from_classname($classname) |
|
134 | + { |
|
135 | + if (! class_exists($classname)) { |
|
136 | + throw new BatchRequestException( |
|
137 | + sprintf( |
|
138 | + __( |
|
139 | + 'The class %1$s does not exist, and so could not be used for running a job. It should implement JobHandlerInterface.', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + $classname |
|
143 | + ) |
|
144 | + ); |
|
145 | + } |
|
146 | + $obj = new $classname; |
|
147 | + if (! $obj instanceof JobHandlerInterface) { |
|
148 | + throw new BatchRequestException( |
|
149 | + sprintf( |
|
150 | + __( |
|
151 | + 'The class %1$s does not implement JobHandlerInterface and so could not be used for running a job', |
|
152 | + 'event_espresso' |
|
153 | + ), |
|
154 | + $classname |
|
155 | + ) |
|
156 | + ); |
|
157 | + } |
|
158 | + return $obj; |
|
159 | + } |
|
160 | 160 | |
161 | 161 | |
162 | - /** |
|
163 | - * Forces a job to be cleaned up |
|
164 | - * |
|
165 | - * @param string $job_id |
|
166 | - * @return JobStepResponse |
|
167 | - * @throws BatchRequestException |
|
168 | - */ |
|
169 | - public function cleanup_job($job_id) |
|
170 | - { |
|
171 | - try { |
|
172 | - $this->_job_id = $job_id; |
|
173 | - $job_parameters = JobParameters::load($this->_job_id); |
|
174 | - $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
175 | - // continue it |
|
176 | - $response = $handler_obj->cleanup_job($job_parameters); |
|
177 | - if (! $response instanceof JobStepResponse) { |
|
178 | - throw new BatchRequestException( |
|
179 | - sprintf( |
|
180 | - __( |
|
181 | - 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', |
|
182 | - 'event_espresso' |
|
183 | - ), |
|
184 | - $this->_job_id |
|
185 | - ) |
|
186 | - ); |
|
187 | - } |
|
188 | - $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
189 | - $job_parameters->delete(); |
|
190 | - return $response; |
|
191 | - } catch (\Exception $e) { |
|
192 | - $response = $this->_get_error_response($e, 'cleanup_job'); |
|
193 | - } |
|
194 | - return $response; |
|
195 | - } |
|
162 | + /** |
|
163 | + * Forces a job to be cleaned up |
|
164 | + * |
|
165 | + * @param string $job_id |
|
166 | + * @return JobStepResponse |
|
167 | + * @throws BatchRequestException |
|
168 | + */ |
|
169 | + public function cleanup_job($job_id) |
|
170 | + { |
|
171 | + try { |
|
172 | + $this->_job_id = $job_id; |
|
173 | + $job_parameters = JobParameters::load($this->_job_id); |
|
174 | + $handler_obj = $this->instantiate_batch_job_handler_from_classname($job_parameters->classname()); |
|
175 | + // continue it |
|
176 | + $response = $handler_obj->cleanup_job($job_parameters); |
|
177 | + if (! $response instanceof JobStepResponse) { |
|
178 | + throw new BatchRequestException( |
|
179 | + sprintf( |
|
180 | + __( |
|
181 | + 'The class implementing JobHandlerInterface did not return a JobStepResponse when cleanup_job was called with job %1$s. It needs to return one or throw an Exception', |
|
182 | + 'event_espresso' |
|
183 | + ), |
|
184 | + $this->_job_id |
|
185 | + ) |
|
186 | + ); |
|
187 | + } |
|
188 | + $job_parameters->set_status(JobParameters::status_cleaned_up); |
|
189 | + $job_parameters->delete(); |
|
190 | + return $response; |
|
191 | + } catch (\Exception $e) { |
|
192 | + $response = $this->_get_error_response($e, 'cleanup_job'); |
|
193 | + } |
|
194 | + return $response; |
|
195 | + } |
|
196 | 196 | |
197 | 197 | |
198 | - /** |
|
199 | - * Creates a valid JobStepResponse object from an exception and method name. |
|
200 | - * |
|
201 | - * @param \Exception $exception |
|
202 | - * @param string $method_name |
|
203 | - * @return JobStepResponse |
|
204 | - */ |
|
205 | - protected function _get_error_response(\Exception $exception, $method_name) |
|
206 | - { |
|
207 | - if (! $this->_job_parameters instanceof JobParameters) { |
|
208 | - $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
209 | - } |
|
210 | - $this->_job_parameters->set_status(JobParameters::status_error); |
|
211 | - return new JobStepResponse( |
|
212 | - $this->_job_parameters, |
|
213 | - sprintf( |
|
214 | - __( |
|
215 | - 'An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', |
|
216 | - 'event_espresso' |
|
217 | - ), |
|
218 | - get_class($exception), |
|
219 | - 'BatchRunner::' . $method_name . '()', |
|
220 | - $exception->getMessage(), |
|
221 | - $exception->getTraceAsString() |
|
222 | - ) |
|
223 | - ); |
|
224 | - } |
|
198 | + /** |
|
199 | + * Creates a valid JobStepResponse object from an exception and method name. |
|
200 | + * |
|
201 | + * @param \Exception $exception |
|
202 | + * @param string $method_name |
|
203 | + * @return JobStepResponse |
|
204 | + */ |
|
205 | + protected function _get_error_response(\Exception $exception, $method_name) |
|
206 | + { |
|
207 | + if (! $this->_job_parameters instanceof JobParameters) { |
|
208 | + $this->_job_parameters = new JobParameters($this->_job_id, __('__Unknown__', 'event_espresso'), array()); |
|
209 | + } |
|
210 | + $this->_job_parameters->set_status(JobParameters::status_error); |
|
211 | + return new JobStepResponse( |
|
212 | + $this->_job_parameters, |
|
213 | + sprintf( |
|
214 | + __( |
|
215 | + 'An exception of type %1$s occurred while running %2$s. Its message was %3$s and had trace %4$s', |
|
216 | + 'event_espresso' |
|
217 | + ), |
|
218 | + get_class($exception), |
|
219 | + 'BatchRunner::' . $method_name . '()', |
|
220 | + $exception->getMessage(), |
|
221 | + $exception->getTraceAsString() |
|
222 | + ) |
|
223 | + ); |
|
224 | + } |
|
225 | 225 | } |
@@ -4,63 +4,63 @@ |
||
4 | 4 | |
5 | 5 | interface HasSchemaInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * Returns whatever is set as the nicename for the object. |
|
9 | - * |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function getSchemaDescription(); |
|
7 | + /** |
|
8 | + * Returns whatever is set as the nicename for the object. |
|
9 | + * |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function getSchemaDescription(); |
|
13 | 13 | |
14 | 14 | |
15 | - /** |
|
16 | - * Returns whatever is set as the $_schema_type property for the object. |
|
17 | - * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
18 | - * |
|
19 | - * @return string|array |
|
20 | - */ |
|
21 | - public function getSchemaType(); |
|
15 | + /** |
|
16 | + * Returns whatever is set as the $_schema_type property for the object. |
|
17 | + * Note: this will automatically add 'null' to the schema if the object is_nullable() |
|
18 | + * |
|
19 | + * @return string|array |
|
20 | + */ |
|
21 | + public function getSchemaType(); |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
26 | - * this method and return the properties for the schema. |
|
27 | - * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
28 | - * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - public function getSchemaProperties(); |
|
24 | + /** |
|
25 | + * This is usually present when the $_schema_type property is 'object'. Any child classes will need to override |
|
26 | + * this method and return the properties for the schema. |
|
27 | + * The reason this is not a property on the class is because there may be filters set on the values for the property |
|
28 | + * that won't be exposed on construct. For example enum type schemas may have the enum values filtered. |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + public function getSchemaProperties(); |
|
33 | 33 | |
34 | - /** |
|
35 | - * If a child class has enum values, they should override this method and provide a simple array |
|
36 | - * of the enum values. |
|
37 | - * The reason this is not a property on the class is because there may be filterable enum values that |
|
38 | - * are set on the instantiated object that could be filtered after construct. |
|
39 | - * |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - public function getSchemaEnum(); |
|
34 | + /** |
|
35 | + * If a child class has enum values, they should override this method and provide a simple array |
|
36 | + * of the enum values. |
|
37 | + * The reason this is not a property on the class is because there may be filterable enum values that |
|
38 | + * are set on the instantiated object that could be filtered after construct. |
|
39 | + * |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + public function getSchemaEnum(); |
|
43 | 43 | |
44 | - /** |
|
45 | - * This returns the value of the $_schema_format property on the object. |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getSchemaFormat(); |
|
44 | + /** |
|
45 | + * This returns the value of the $_schema_format property on the object. |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getSchemaFormat(); |
|
50 | 50 | |
51 | - /** |
|
52 | - * This returns the value of the $_schema_readonly property on the object. |
|
53 | - * |
|
54 | - * @return bool |
|
55 | - */ |
|
56 | - public function getSchemaReadonly(); |
|
51 | + /** |
|
52 | + * This returns the value of the $_schema_readonly property on the object. |
|
53 | + * |
|
54 | + * @return bool |
|
55 | + */ |
|
56 | + public function getSchemaReadonly(); |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * This returns elements used to represent this field in the json schema. |
|
61 | - * |
|
62 | - * @link http://json-schema.org/ |
|
63 | - * @return array |
|
64 | - */ |
|
65 | - public function getSchema(); |
|
59 | + /** |
|
60 | + * This returns elements used to represent this field in the json schema. |
|
61 | + * |
|
62 | + * @link http://json-schema.org/ |
|
63 | + * @return array |
|
64 | + */ |
|
65 | + public function getSchema(); |
|
66 | 66 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | */ |
13 | 13 | interface CaffeinatedInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * Used to indicate when functionality is caffeinated or not. |
|
17 | - * @return bool |
|
18 | - */ |
|
19 | - public function isCaffeinated(); |
|
15 | + /** |
|
16 | + * Used to indicate when functionality is caffeinated or not. |
|
17 | + * @return bool |
|
18 | + */ |
|
19 | + public function isCaffeinated(); |
|
20 | 20 | } |
@@ -16,131 +16,131 @@ |
||
16 | 16 | */ |
17 | 17 | class Config |
18 | 18 | { |
19 | - /** |
|
20 | - * @var EE_Network_Config |
|
21 | - */ |
|
22 | - private $network_config; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @var EE_Config |
|
27 | - */ |
|
28 | - private $ee_config; |
|
29 | - |
|
30 | - |
|
31 | - public function __construct(EE_Network_Config $network_config, EE_Config $ee_config) |
|
32 | - { |
|
33 | - $this->network_config = $network_config; |
|
34 | - $this->ee_config = $ee_config; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Get the site license key for the site. |
|
40 | - */ |
|
41 | - public function siteLicenseKey() |
|
42 | - { |
|
43 | - return $this->network_config->core->site_license_key; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - public function i18nDomain() |
|
48 | - { |
|
49 | - return 'event_espresso'; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - public function checkPeriod() |
|
54 | - { |
|
55 | - return 24; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - public function optionKey() |
|
60 | - { |
|
61 | - return 'site_license_key'; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - public function optionsPageSlug() |
|
66 | - { |
|
67 | - return 'espresso_general_settings'; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - public function hostServerUrl() |
|
72 | - { |
|
73 | - return defined('PUE_UPDATES_ENDPOINT') |
|
74 | - ? PUE_UPDATES_ENDPOINT |
|
75 | - : 'https://eventespresso.com'; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - public function pluginSlug() |
|
80 | - { |
|
81 | - // Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
82 | - // So it's important that you use a key for the version type that is unique and not found in another key. |
|
83 | - // For example: |
|
84 | - // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
85 | - // $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
86 | - // The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr ) |
|
87 | - // so doing something like: |
|
88 | - // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
89 | - // $plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
90 | - // ..WOULD work! |
|
91 | - return array( |
|
92 | - 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
93 | - 'premium' => array('p' => 'event-espresso-core-reg'), |
|
94 | - 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
95 | - ); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Return whether the site is opted in for UXIP or not. |
|
101 | - * |
|
102 | - * @return bool |
|
103 | - */ |
|
104 | - public function isOptedInForUxip() |
|
105 | - { |
|
106 | - return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Return whether the site has been notified about UXIP or not. |
|
112 | - * |
|
113 | - * @return bool |
|
114 | - */ |
|
115 | - public function hasNotifiedForUxip() |
|
116 | - { |
|
117 | - return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
118 | - } |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * Set the site opted in for UXIP. |
|
123 | - */ |
|
124 | - public function setHasOptedInForUxip() |
|
125 | - { |
|
126 | - $this->ee_config->core->ee_ueip_optin = true; |
|
127 | - $this->ee_config->update_espresso_config(false, false); |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * Set the site opted out for UXIP |
|
133 | - */ |
|
134 | - public function setHasOptedOutForUxip() |
|
135 | - { |
|
136 | - $this->ee_config->core->ee_ueip_optin = false; |
|
137 | - $this->ee_config->update_espresso_config(false, false); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - public function setHasNotifiedAboutUxip() |
|
142 | - { |
|
143 | - $this->ee_config->core->ee_ueip_has_notified = true; |
|
144 | - $this->ee_config->update_espresso_config(false, false); |
|
145 | - } |
|
19 | + /** |
|
20 | + * @var EE_Network_Config |
|
21 | + */ |
|
22 | + private $network_config; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @var EE_Config |
|
27 | + */ |
|
28 | + private $ee_config; |
|
29 | + |
|
30 | + |
|
31 | + public function __construct(EE_Network_Config $network_config, EE_Config $ee_config) |
|
32 | + { |
|
33 | + $this->network_config = $network_config; |
|
34 | + $this->ee_config = $ee_config; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * Get the site license key for the site. |
|
40 | + */ |
|
41 | + public function siteLicenseKey() |
|
42 | + { |
|
43 | + return $this->network_config->core->site_license_key; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + public function i18nDomain() |
|
48 | + { |
|
49 | + return 'event_espresso'; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + public function checkPeriod() |
|
54 | + { |
|
55 | + return 24; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + public function optionKey() |
|
60 | + { |
|
61 | + return 'site_license_key'; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + public function optionsPageSlug() |
|
66 | + { |
|
67 | + return 'espresso_general_settings'; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + public function hostServerUrl() |
|
72 | + { |
|
73 | + return defined('PUE_UPDATES_ENDPOINT') |
|
74 | + ? PUE_UPDATES_ENDPOINT |
|
75 | + : 'https://eventespresso.com'; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + public function pluginSlug() |
|
80 | + { |
|
81 | + // Note: PUE uses a simple preg_match to determine what type is currently installed based on version number. |
|
82 | + // So it's important that you use a key for the version type that is unique and not found in another key. |
|
83 | + // For example: |
|
84 | + // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
85 | + // $plugin_slug['prerelease']['pr'] = 'some-pre-release-slug'; |
|
86 | + // The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr ) |
|
87 | + // so doing something like: |
|
88 | + // $plugin_slug['premium']['p'] = 'some-premium-slug'; |
|
89 | + // $plugin_slug['prerelease']['b'] = 'some-pre-release-slug'; |
|
90 | + // ..WOULD work! |
|
91 | + return array( |
|
92 | + 'free' => array('decaf' => 'event-espresso-core-decaf'), |
|
93 | + 'premium' => array('p' => 'event-espresso-core-reg'), |
|
94 | + 'prerelease' => array('beta' => 'event-espresso-core-pr'), |
|
95 | + ); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Return whether the site is opted in for UXIP or not. |
|
101 | + * |
|
102 | + * @return bool |
|
103 | + */ |
|
104 | + public function isOptedInForUxip() |
|
105 | + { |
|
106 | + return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Return whether the site has been notified about UXIP or not. |
|
112 | + * |
|
113 | + * @return bool |
|
114 | + */ |
|
115 | + public function hasNotifiedForUxip() |
|
116 | + { |
|
117 | + return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN); |
|
118 | + } |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * Set the site opted in for UXIP. |
|
123 | + */ |
|
124 | + public function setHasOptedInForUxip() |
|
125 | + { |
|
126 | + $this->ee_config->core->ee_ueip_optin = true; |
|
127 | + $this->ee_config->update_espresso_config(false, false); |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * Set the site opted out for UXIP |
|
133 | + */ |
|
134 | + public function setHasOptedOutForUxip() |
|
135 | + { |
|
136 | + $this->ee_config->core->ee_ueip_optin = false; |
|
137 | + $this->ee_config->update_espresso_config(false, false); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + public function setHasNotifiedAboutUxip() |
|
142 | + { |
|
143 | + $this->ee_config->core->ee_ueip_has_notified = true; |
|
144 | + $this->ee_config->update_espresso_config(false, false); |
|
145 | + } |
|
146 | 146 | } |
@@ -5,8 +5,8 @@ |
||
5 | 5 | interface SessionIdentifierInterface |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @return string |
|
10 | - */ |
|
11 | - public function id(); |
|
8 | + /** |
|
9 | + * @return string |
|
10 | + */ |
|
11 | + public function id(); |
|
12 | 12 | } |