@@ -36,7 +36,7 @@ |
||
| 36 | 36 | $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
| 37 | 37 | foreach ($notices->getError() as $notice) { |
| 38 | 38 | if ($this->getThrowExceptions()) { |
| 39 | - $error_string .= '<br />' . $notice->message(); |
|
| 39 | + $error_string .= '<br />'.$notice->message(); |
|
| 40 | 40 | } else { |
| 41 | 41 | new AdminNotice($notice); |
| 42 | 42 | } |
@@ -13,42 +13,42 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class ConvertNoticesToAdminNotices extends NoticeConverter |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Converts Notice objects into AdminNotice notifications |
|
| 18 | - * |
|
| 19 | - * @param NoticesContainerInterface $notices |
|
| 20 | - * @throws DomainException |
|
| 21 | - */ |
|
| 22 | - public function process(NoticesContainerInterface $notices) |
|
| 23 | - { |
|
| 24 | - if ($notices->hasAttention()) { |
|
| 25 | - foreach ($notices->getAttention() as $notice) { |
|
| 26 | - new AdminNotice($notice); |
|
| 27 | - } |
|
| 28 | - } |
|
| 29 | - if ($notices->hasError()) { |
|
| 30 | - $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
| 31 | - foreach ($notices->getError() as $notice) { |
|
| 32 | - if ($this->getThrowExceptions()) { |
|
| 33 | - $error_string .= '<br />' . $notice->message(); |
|
| 34 | - } else { |
|
| 35 | - new AdminNotice($notice); |
|
| 36 | - } |
|
| 37 | - } |
|
| 38 | - if ($this->getThrowExceptions()) { |
|
| 39 | - throw new DomainException($error_string); |
|
| 40 | - } |
|
| 41 | - } |
|
| 42 | - if ($notices->hasSuccess()) { |
|
| 43 | - foreach ($notices->getSuccess() as $notice) { |
|
| 44 | - new AdminNotice($notice); |
|
| 45 | - } |
|
| 46 | - } |
|
| 47 | - if ($notices->hasInformation()) { |
|
| 48 | - foreach ($notices->getInformation() as $notice) { |
|
| 49 | - new AdminNotice($notice); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - $this->clearNotices(); |
|
| 53 | - } |
|
| 16 | + /** |
|
| 17 | + * Converts Notice objects into AdminNotice notifications |
|
| 18 | + * |
|
| 19 | + * @param NoticesContainerInterface $notices |
|
| 20 | + * @throws DomainException |
|
| 21 | + */ |
|
| 22 | + public function process(NoticesContainerInterface $notices) |
|
| 23 | + { |
|
| 24 | + if ($notices->hasAttention()) { |
|
| 25 | + foreach ($notices->getAttention() as $notice) { |
|
| 26 | + new AdminNotice($notice); |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | + if ($notices->hasError()) { |
|
| 30 | + $error_string = esc_html__('The following errors occurred:', 'event_espresso'); |
|
| 31 | + foreach ($notices->getError() as $notice) { |
|
| 32 | + if ($this->getThrowExceptions()) { |
|
| 33 | + $error_string .= '<br />' . $notice->message(); |
|
| 34 | + } else { |
|
| 35 | + new AdminNotice($notice); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | + if ($this->getThrowExceptions()) { |
|
| 39 | + throw new DomainException($error_string); |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | + if ($notices->hasSuccess()) { |
|
| 43 | + foreach ($notices->getSuccess() as $notice) { |
|
| 44 | + new AdminNotice($notice); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | + if ($notices->hasInformation()) { |
|
| 48 | + foreach ($notices->getInformation() as $notice) { |
|
| 49 | + new AdminNotice($notice); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + $this->clearNotices(); |
|
| 53 | + } |
|
| 54 | 54 | } |
@@ -91,7 +91,7 @@ |
||
| 91 | 91 | public function __construct($slug, $description) |
| 92 | 92 | { |
| 93 | 93 | parent::__construct($slug, $description); |
| 94 | - if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
| 94 | + if ( ! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
| 95 | 95 | throw new InvalidArgumentException( |
| 96 | 96 | sprintf( |
| 97 | 97 | esc_html__( |
@@ -15,185 +15,185 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class RequestTypeContext extends Context |
| 17 | 17 | { |
| 18 | - /** |
|
| 19 | - * indicates that the current request involves some form of activation |
|
| 20 | - */ |
|
| 21 | - const ACTIVATION = 'activation-request'; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * indicates that the current request is for the admin but is not being made via AJAX |
|
| 25 | - */ |
|
| 26 | - const ADMIN = 'non-ajax-admin-request'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * indicates that the current request is for the admin AND is being made via AJAX |
|
| 30 | - */ |
|
| 31 | - const AJAX_ADMIN = 'admin-ajax-request'; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * indicates that the current request is for the frontend AND is being made via AJAX |
|
| 35 | - */ |
|
| 36 | - const AJAX_FRONT = 'frontend-ajax-request'; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * indicates that the current request is for the WP Heartbeat |
|
| 40 | - */ |
|
| 41 | - const AJAX_HEARTBEAT = 'admin-ajax-heartbeat'; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * indicates that the current request is being made via AJAX, but is NOT for EE |
|
| 45 | - */ |
|
| 46 | - const AJAX_OTHER = 'other-ajax-request'; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * indicates that the current request is for the EE REST API |
|
| 50 | - */ |
|
| 51 | - const API = 'rest-api'; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * indicates that the current request is from the command line |
|
| 55 | - */ |
|
| 56 | - const CLI = 'command-line'; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * indicates that the current request is for a WP_Cron |
|
| 60 | - */ |
|
| 61 | - const CRON = 'wp-cron'; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * indicates that the current request is for a feed (ie: RSS) |
|
| 65 | - */ |
|
| 66 | - const FEED = 'feed-request'; |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * indicates that the current request is for the frontend but is not being made via AJAX |
|
| 70 | - */ |
|
| 71 | - const FRONTEND = 'non-ajax-frontend-request'; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * indicates that the current request is for content that is to be displayed within an iframe |
|
| 75 | - */ |
|
| 76 | - const IFRAME = 'iframe-request'; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * indicates that the current request is for the EE GraphQL manager |
|
| 80 | - */ |
|
| 81 | - const GQL = 'graphql'; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * indicates that the current request is for the WP REST API |
|
| 85 | - */ |
|
| 86 | - const WP_API = 'wp-rest-api'; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * indicates that the current request is a loopback sent from WP core to test for errors |
|
| 90 | - */ |
|
| 91 | - const WP_SCRAPE = 'wordpress-scrape'; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @var boolean $is_activation |
|
| 95 | - */ |
|
| 96 | - private bool $is_activation = false; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @var boolean $is_unit_testing |
|
| 100 | - */ |
|
| 101 | - private bool $is_unit_testing = false; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @var array $valid_request_types |
|
| 105 | - */ |
|
| 106 | - private array $valid_request_types = array(); |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * RequestTypeContext constructor. |
|
| 111 | - * |
|
| 112 | - * @param string $slug |
|
| 113 | - * @param string $description |
|
| 114 | - * @throws InvalidArgumentException |
|
| 115 | - */ |
|
| 116 | - public function __construct($slug, $description) |
|
| 117 | - { |
|
| 118 | - parent::__construct($slug, $description); |
|
| 119 | - if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
| 120 | - throw new InvalidArgumentException( |
|
| 121 | - sprintf( |
|
| 122 | - esc_html__( |
|
| 123 | - 'The RequestTypeContext slug must be one of the following values: %1$s %2$s', |
|
| 124 | - 'event_espresso' |
|
| 125 | - ), |
|
| 126 | - '<br />', |
|
| 127 | - var_export($this->validRequestTypes(), true) |
|
| 128 | - ) |
|
| 129 | - ); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - /** |
|
| 135 | - * @return array |
|
| 136 | - */ |
|
| 137 | - public function validRequestTypes(): array |
|
| 138 | - { |
|
| 139 | - if (empty($this->valid_request_types)) { |
|
| 140 | - $this->valid_request_types = apply_filters( |
|
| 141 | - 'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes', |
|
| 142 | - array( |
|
| 143 | - RequestTypeContext::ACTIVATION, |
|
| 144 | - RequestTypeContext::ADMIN, |
|
| 145 | - RequestTypeContext::AJAX_ADMIN, |
|
| 146 | - RequestTypeContext::AJAX_FRONT, |
|
| 147 | - RequestTypeContext::AJAX_HEARTBEAT, |
|
| 148 | - RequestTypeContext::AJAX_OTHER, |
|
| 149 | - RequestTypeContext::API, |
|
| 150 | - RequestTypeContext::CLI, |
|
| 151 | - RequestTypeContext::CRON, |
|
| 152 | - RequestTypeContext::FEED, |
|
| 153 | - RequestTypeContext::FRONTEND, |
|
| 154 | - RequestTypeContext::GQL, |
|
| 155 | - RequestTypeContext::IFRAME, |
|
| 156 | - RequestTypeContext::WP_API, |
|
| 157 | - RequestTypeContext::WP_SCRAPE, |
|
| 158 | - ) |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - return $this->valid_request_types; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * @return bool |
|
| 167 | - */ |
|
| 168 | - public function isActivation(): bool |
|
| 169 | - { |
|
| 170 | - return $this->is_activation || $this->slug() === RequestTypeContext::ACTIVATION; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @param bool $is_activation |
|
| 176 | - */ |
|
| 177 | - public function setIsActivation(bool $is_activation = false) |
|
| 178 | - { |
|
| 179 | - $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - public function isUnitTesting(): bool |
|
| 187 | - { |
|
| 188 | - return $this->is_unit_testing; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - /** |
|
| 193 | - * @param bool $is_unit_testing |
|
| 194 | - */ |
|
| 195 | - public function setIsUnitTesting(bool $is_unit_testing = false) |
|
| 196 | - { |
|
| 197 | - $this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN); |
|
| 198 | - } |
|
| 18 | + /** |
|
| 19 | + * indicates that the current request involves some form of activation |
|
| 20 | + */ |
|
| 21 | + const ACTIVATION = 'activation-request'; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * indicates that the current request is for the admin but is not being made via AJAX |
|
| 25 | + */ |
|
| 26 | + const ADMIN = 'non-ajax-admin-request'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * indicates that the current request is for the admin AND is being made via AJAX |
|
| 30 | + */ |
|
| 31 | + const AJAX_ADMIN = 'admin-ajax-request'; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * indicates that the current request is for the frontend AND is being made via AJAX |
|
| 35 | + */ |
|
| 36 | + const AJAX_FRONT = 'frontend-ajax-request'; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * indicates that the current request is for the WP Heartbeat |
|
| 40 | + */ |
|
| 41 | + const AJAX_HEARTBEAT = 'admin-ajax-heartbeat'; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * indicates that the current request is being made via AJAX, but is NOT for EE |
|
| 45 | + */ |
|
| 46 | + const AJAX_OTHER = 'other-ajax-request'; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * indicates that the current request is for the EE REST API |
|
| 50 | + */ |
|
| 51 | + const API = 'rest-api'; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * indicates that the current request is from the command line |
|
| 55 | + */ |
|
| 56 | + const CLI = 'command-line'; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * indicates that the current request is for a WP_Cron |
|
| 60 | + */ |
|
| 61 | + const CRON = 'wp-cron'; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * indicates that the current request is for a feed (ie: RSS) |
|
| 65 | + */ |
|
| 66 | + const FEED = 'feed-request'; |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * indicates that the current request is for the frontend but is not being made via AJAX |
|
| 70 | + */ |
|
| 71 | + const FRONTEND = 'non-ajax-frontend-request'; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * indicates that the current request is for content that is to be displayed within an iframe |
|
| 75 | + */ |
|
| 76 | + const IFRAME = 'iframe-request'; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * indicates that the current request is for the EE GraphQL manager |
|
| 80 | + */ |
|
| 81 | + const GQL = 'graphql'; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * indicates that the current request is for the WP REST API |
|
| 85 | + */ |
|
| 86 | + const WP_API = 'wp-rest-api'; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * indicates that the current request is a loopback sent from WP core to test for errors |
|
| 90 | + */ |
|
| 91 | + const WP_SCRAPE = 'wordpress-scrape'; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @var boolean $is_activation |
|
| 95 | + */ |
|
| 96 | + private bool $is_activation = false; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @var boolean $is_unit_testing |
|
| 100 | + */ |
|
| 101 | + private bool $is_unit_testing = false; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @var array $valid_request_types |
|
| 105 | + */ |
|
| 106 | + private array $valid_request_types = array(); |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * RequestTypeContext constructor. |
|
| 111 | + * |
|
| 112 | + * @param string $slug |
|
| 113 | + * @param string $description |
|
| 114 | + * @throws InvalidArgumentException |
|
| 115 | + */ |
|
| 116 | + public function __construct($slug, $description) |
|
| 117 | + { |
|
| 118 | + parent::__construct($slug, $description); |
|
| 119 | + if (! in_array($this->slug(), $this->validRequestTypes(), true)) { |
|
| 120 | + throw new InvalidArgumentException( |
|
| 121 | + sprintf( |
|
| 122 | + esc_html__( |
|
| 123 | + 'The RequestTypeContext slug must be one of the following values: %1$s %2$s', |
|
| 124 | + 'event_espresso' |
|
| 125 | + ), |
|
| 126 | + '<br />', |
|
| 127 | + var_export($this->validRequestTypes(), true) |
|
| 128 | + ) |
|
| 129 | + ); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + /** |
|
| 135 | + * @return array |
|
| 136 | + */ |
|
| 137 | + public function validRequestTypes(): array |
|
| 138 | + { |
|
| 139 | + if (empty($this->valid_request_types)) { |
|
| 140 | + $this->valid_request_types = apply_filters( |
|
| 141 | + 'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes', |
|
| 142 | + array( |
|
| 143 | + RequestTypeContext::ACTIVATION, |
|
| 144 | + RequestTypeContext::ADMIN, |
|
| 145 | + RequestTypeContext::AJAX_ADMIN, |
|
| 146 | + RequestTypeContext::AJAX_FRONT, |
|
| 147 | + RequestTypeContext::AJAX_HEARTBEAT, |
|
| 148 | + RequestTypeContext::AJAX_OTHER, |
|
| 149 | + RequestTypeContext::API, |
|
| 150 | + RequestTypeContext::CLI, |
|
| 151 | + RequestTypeContext::CRON, |
|
| 152 | + RequestTypeContext::FEED, |
|
| 153 | + RequestTypeContext::FRONTEND, |
|
| 154 | + RequestTypeContext::GQL, |
|
| 155 | + RequestTypeContext::IFRAME, |
|
| 156 | + RequestTypeContext::WP_API, |
|
| 157 | + RequestTypeContext::WP_SCRAPE, |
|
| 158 | + ) |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + return $this->valid_request_types; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * @return bool |
|
| 167 | + */ |
|
| 168 | + public function isActivation(): bool |
|
| 169 | + { |
|
| 170 | + return $this->is_activation || $this->slug() === RequestTypeContext::ACTIVATION; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @param bool $is_activation |
|
| 176 | + */ |
|
| 177 | + public function setIsActivation(bool $is_activation = false) |
|
| 178 | + { |
|
| 179 | + $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + public function isUnitTesting(): bool |
|
| 187 | + { |
|
| 188 | + return $this->is_unit_testing; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @param bool $is_unit_testing |
|
| 194 | + */ |
|
| 195 | + public function setIsUnitTesting(bool $is_unit_testing = false) |
|
| 196 | + { |
|
| 197 | + $this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN); |
|
| 198 | + } |
|
| 199 | 199 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | */ |
| 52 | 52 | public function wp_user_obj() |
| 53 | 53 | { |
| 54 | - if (! $this->_wp_user_obj) { |
|
| 54 | + if ( ! $this->_wp_user_obj) { |
|
| 55 | 55 | $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
| 56 | 56 | } |
| 57 | 57 | return $this->_wp_user_obj; |
@@ -12,111 +12,111 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var WP_User |
|
| 17 | - */ |
|
| 18 | - protected $_wp_user_obj; |
|
| 19 | - |
|
| 20 | - |
|
| 21 | - /** |
|
| 22 | - * @param array $props_n_values |
|
| 23 | - * @return EE_WP_User|mixed |
|
| 24 | - * @throws EE_Error |
|
| 25 | - * @throws ReflectionException |
|
| 26 | - */ |
|
| 27 | - public static function new_instance($props_n_values = []) |
|
| 28 | - { |
|
| 29 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 30 | - return $has_object ?: new self($props_n_values); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @param array $props_n_values |
|
| 36 | - * @return EE_WP_User |
|
| 37 | - * @throws EE_Error |
|
| 38 | - * @throws ReflectionException |
|
| 39 | - */ |
|
| 40 | - public static function new_instance_from_db($props_n_values = []) |
|
| 41 | - { |
|
| 42 | - return new self($props_n_values, true); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * Return a normal WP_User object (caches the object for future calls) |
|
| 48 | - * |
|
| 49 | - * @return WP_User |
|
| 50 | - * @throws EE_Error |
|
| 51 | - * @throws ReflectionException |
|
| 52 | - */ |
|
| 53 | - public function wp_user_obj() |
|
| 54 | - { |
|
| 55 | - if (! $this->_wp_user_obj) { |
|
| 56 | - $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 57 | - } |
|
| 58 | - return $this->_wp_user_obj; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * Return the link to the admin details for the object. |
|
| 64 | - * |
|
| 65 | - * @return string |
|
| 66 | - * @throws EE_Error |
|
| 67 | - * @throws ReflectionException |
|
| 68 | - */ |
|
| 69 | - public function get_admin_details_link() |
|
| 70 | - { |
|
| 71 | - return $this->get_admin_edit_link(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 77 | - * |
|
| 78 | - * @return string |
|
| 79 | - * @throws EE_Error |
|
| 80 | - * @throws ReflectionException |
|
| 81 | - */ |
|
| 82 | - public function get_admin_edit_link() |
|
| 83 | - { |
|
| 84 | - /** @var RequestInterface $request */ |
|
| 85 | - $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
| 86 | - return esc_url( |
|
| 87 | - add_query_arg( |
|
| 88 | - 'wp_http_referer', |
|
| 89 | - urlencode( |
|
| 90 | - wp_unslash( |
|
| 91 | - $request->getServerParam('REQUEST_URI') |
|
| 92 | - ) |
|
| 93 | - ), |
|
| 94 | - get_edit_user_link($this->ID()) |
|
| 95 | - ) |
|
| 96 | - ); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * Returns the link to a settings page for the object. |
|
| 102 | - * |
|
| 103 | - * @return string |
|
| 104 | - * @throws EE_Error |
|
| 105 | - * @throws ReflectionException |
|
| 106 | - */ |
|
| 107 | - public function get_admin_settings_link() |
|
| 108 | - { |
|
| 109 | - return $this->get_admin_edit_link(); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 115 | - * |
|
| 116 | - * @return string |
|
| 117 | - */ |
|
| 118 | - public function get_admin_overview_link() |
|
| 119 | - { |
|
| 120 | - return admin_url('users.php'); |
|
| 121 | - } |
|
| 15 | + /** |
|
| 16 | + * @var WP_User |
|
| 17 | + */ |
|
| 18 | + protected $_wp_user_obj; |
|
| 19 | + |
|
| 20 | + |
|
| 21 | + /** |
|
| 22 | + * @param array $props_n_values |
|
| 23 | + * @return EE_WP_User|mixed |
|
| 24 | + * @throws EE_Error |
|
| 25 | + * @throws ReflectionException |
|
| 26 | + */ |
|
| 27 | + public static function new_instance($props_n_values = []) |
|
| 28 | + { |
|
| 29 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 30 | + return $has_object ?: new self($props_n_values); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @param array $props_n_values |
|
| 36 | + * @return EE_WP_User |
|
| 37 | + * @throws EE_Error |
|
| 38 | + * @throws ReflectionException |
|
| 39 | + */ |
|
| 40 | + public static function new_instance_from_db($props_n_values = []) |
|
| 41 | + { |
|
| 42 | + return new self($props_n_values, true); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * Return a normal WP_User object (caches the object for future calls) |
|
| 48 | + * |
|
| 49 | + * @return WP_User |
|
| 50 | + * @throws EE_Error |
|
| 51 | + * @throws ReflectionException |
|
| 52 | + */ |
|
| 53 | + public function wp_user_obj() |
|
| 54 | + { |
|
| 55 | + if (! $this->_wp_user_obj) { |
|
| 56 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 57 | + } |
|
| 58 | + return $this->_wp_user_obj; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * Return the link to the admin details for the object. |
|
| 64 | + * |
|
| 65 | + * @return string |
|
| 66 | + * @throws EE_Error |
|
| 67 | + * @throws ReflectionException |
|
| 68 | + */ |
|
| 69 | + public function get_admin_details_link() |
|
| 70 | + { |
|
| 71 | + return $this->get_admin_edit_link(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 77 | + * |
|
| 78 | + * @return string |
|
| 79 | + * @throws EE_Error |
|
| 80 | + * @throws ReflectionException |
|
| 81 | + */ |
|
| 82 | + public function get_admin_edit_link() |
|
| 83 | + { |
|
| 84 | + /** @var RequestInterface $request */ |
|
| 85 | + $request = LoaderFactory::getLoader()->getShared(RequestInterface::class); |
|
| 86 | + return esc_url( |
|
| 87 | + add_query_arg( |
|
| 88 | + 'wp_http_referer', |
|
| 89 | + urlencode( |
|
| 90 | + wp_unslash( |
|
| 91 | + $request->getServerParam('REQUEST_URI') |
|
| 92 | + ) |
|
| 93 | + ), |
|
| 94 | + get_edit_user_link($this->ID()) |
|
| 95 | + ) |
|
| 96 | + ); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * Returns the link to a settings page for the object. |
|
| 102 | + * |
|
| 103 | + * @return string |
|
| 104 | + * @throws EE_Error |
|
| 105 | + * @throws ReflectionException |
|
| 106 | + */ |
|
| 107 | + public function get_admin_settings_link() |
|
| 108 | + { |
|
| 109 | + return $this->get_admin_edit_link(); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 115 | + * |
|
| 116 | + * @return string |
|
| 117 | + */ |
|
| 118 | + public function get_admin_overview_link() |
|
| 119 | + { |
|
| 120 | + return admin_url('users.php'); |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -78,7 +78,7 @@ |
||
| 78 | 78 | public function preProductionVersionAdminNotice() |
| 79 | 79 | { |
| 80 | 80 | new PersistentAdminNotice( |
| 81 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
| 81 | + 'preProductionVersionAdminNotice_'.EVENT_ESPRESSO_VERSION, |
|
| 82 | 82 | $this->warningNotice() |
| 83 | 83 | ); |
| 84 | 84 | } |
@@ -18,91 +18,91 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class PreProductionVersionWarning extends Middleware |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * converts a Request to a Response |
|
| 23 | - * |
|
| 24 | - * @param RequestInterface $request |
|
| 25 | - * @param ResponseInterface $response |
|
| 26 | - * @return ResponseInterface |
|
| 27 | - */ |
|
| 28 | - public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface |
|
| 29 | - { |
|
| 30 | - $this->request = $request; |
|
| 31 | - $this->response = $response; |
|
| 32 | - $this->displayPreProductionVersionWarning(); |
|
| 33 | - $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 34 | - return $this->response; |
|
| 35 | - } |
|
| 21 | + /** |
|
| 22 | + * converts a Request to a Response |
|
| 23 | + * |
|
| 24 | + * @param RequestInterface $request |
|
| 25 | + * @param ResponseInterface $response |
|
| 26 | + * @return ResponseInterface |
|
| 27 | + */ |
|
| 28 | + public function handleRequest(RequestInterface $request, ResponseInterface $response): ResponseInterface |
|
| 29 | + { |
|
| 30 | + $this->request = $request; |
|
| 31 | + $this->response = $response; |
|
| 32 | + $this->displayPreProductionVersionWarning(); |
|
| 33 | + $this->response = $this->processRequestStack($this->request, $this->response); |
|
| 34 | + return $this->response; |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
| 40 | - * |
|
| 41 | - * @return void |
|
| 42 | - */ |
|
| 43 | - public function displayPreProductionVersionWarning() |
|
| 44 | - { |
|
| 45 | - // skip AJAX requests |
|
| 46 | - if ($this->request->isAjax()) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - // skip stable releases |
|
| 50 | - if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - // site admin has authorized use of non-stable release candidate for production |
|
| 54 | - if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
| 55 | - return; |
|
| 56 | - } |
|
| 57 | - // post release candidate warning |
|
| 58 | - if ($this->request->isAdmin()) { |
|
| 59 | - add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
| 60 | - } else { |
|
| 61 | - add_action('shutdown', array($this, 'preProductionVersionWarningNotice')); |
|
| 62 | - } |
|
| 63 | - } |
|
| 38 | + /** |
|
| 39 | + * displays message on frontend of site notifying admin that EE has been temporarily placed into maintenance mode |
|
| 40 | + * |
|
| 41 | + * @return void |
|
| 42 | + */ |
|
| 43 | + public function displayPreProductionVersionWarning() |
|
| 44 | + { |
|
| 45 | + // skip AJAX requests |
|
| 46 | + if ($this->request->isAjax()) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + // skip stable releases |
|
| 50 | + if (substr(EVENT_ESPRESSO_VERSION, -5) !== '.beta') { |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + // site admin has authorized use of non-stable release candidate for production |
|
| 54 | + if (defined('ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE') && ALLOW_NON_STABLE_RELEASE_ON_LIVE_SITE) { |
|
| 55 | + return; |
|
| 56 | + } |
|
| 57 | + // post release candidate warning |
|
| 58 | + if ($this->request->isAdmin()) { |
|
| 59 | + add_action('admin_notices', array($this, 'preProductionVersionAdminNotice'), -999); |
|
| 60 | + } else { |
|
| 61 | + add_action('shutdown', array($this, 'preProductionVersionWarningNotice')); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * displays admin notice that current version of EE is not a stable release |
|
| 68 | - * |
|
| 69 | - * @return void |
|
| 70 | - * @throws InvalidDataTypeException |
|
| 71 | - */ |
|
| 72 | - public function preProductionVersionAdminNotice() |
|
| 73 | - { |
|
| 74 | - new PersistentAdminNotice( |
|
| 75 | - 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
| 76 | - $this->warningNotice() |
|
| 77 | - ); |
|
| 78 | - } |
|
| 66 | + /** |
|
| 67 | + * displays admin notice that current version of EE is not a stable release |
|
| 68 | + * |
|
| 69 | + * @return void |
|
| 70 | + * @throws InvalidDataTypeException |
|
| 71 | + */ |
|
| 72 | + public function preProductionVersionAdminNotice() |
|
| 73 | + { |
|
| 74 | + new PersistentAdminNotice( |
|
| 75 | + 'preProductionVersionAdminNotice_' . EVENT_ESPRESSO_VERSION, |
|
| 76 | + $this->warningNotice() |
|
| 77 | + ); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
| 83 | - * |
|
| 84 | - * @return void |
|
| 85 | - */ |
|
| 86 | - public function preProductionVersionWarningNotice() |
|
| 87 | - { |
|
| 88 | - echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
| 89 | - echo wp_kses($this->warningNotice(), AllowedTags::getAllowedTags()); |
|
| 90 | - echo '</p></div>'; |
|
| 91 | - } |
|
| 81 | + /** |
|
| 82 | + * displays message on frontend of site notifying admin that current version of EE is not a stable release |
|
| 83 | + * |
|
| 84 | + * @return void |
|
| 85 | + */ |
|
| 86 | + public function preProductionVersionWarningNotice() |
|
| 87 | + { |
|
| 88 | + echo '<div id="ee-release-candidate-notice-dv" class="ee-really-important-notice-dv"><p>'; |
|
| 89 | + echo wp_kses($this->warningNotice(), AllowedTags::getAllowedTags()); |
|
| 90 | + echo '</p></div>'; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - private function warningNotice(): string |
|
| 98 | - { |
|
| 99 | - return sprintf( |
|
| 100 | - esc_html__( |
|
| 101 | - 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
| 102 | - 'event_espresso' |
|
| 103 | - ), |
|
| 104 | - '<strong>', |
|
| 105 | - '</strong>' |
|
| 106 | - ); |
|
| 107 | - } |
|
| 94 | + /** |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + private function warningNotice(): string |
|
| 98 | + { |
|
| 99 | + return sprintf( |
|
| 100 | + esc_html__( |
|
| 101 | + 'This version of Event Espresso is for testing and/or evaluation purposes only. It is %1$snot%2$s considered a stable release and should therefore %1$snot%2$s be activated on a live or production website.', |
|
| 102 | + 'event_espresso' |
|
| 103 | + ), |
|
| 104 | + '<strong>', |
|
| 105 | + '</strong>' |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -74,7 +74,7 @@ |
||
| 74 | 74 | { |
| 75 | 75 | $this->request = $request; |
| 76 | 76 | $this->response = $response; |
| 77 | - if (! $this->response->requestTerminated()) { |
|
| 77 | + if ( ! $this->response->requestTerminated()) { |
|
| 78 | 78 | $this->response = $this->request_stack_app->handleRequest($this->request, $this->response); |
| 79 | 79 | } |
| 80 | 80 | return $this->response; |
@@ -24,40 +24,40 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | abstract class Middleware implements RequestDecoratorInterface |
| 26 | 26 | { |
| 27 | - protected LoaderInterface $loader; |
|
| 28 | - |
|
| 29 | - protected RequestDecoratorInterface $request_stack_app; |
|
| 30 | - |
|
| 31 | - protected RequestInterface $request; |
|
| 32 | - |
|
| 33 | - protected ResponseInterface $response; |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @param RequestDecoratorInterface $request_stack_app |
|
| 38 | - * @param LoaderInterface $loader |
|
| 39 | - */ |
|
| 40 | - public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader) |
|
| 41 | - { |
|
| 42 | - $this->request_stack_app = $request_stack_app; |
|
| 43 | - $this->loader = $loader; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * process_request_stack |
|
| 49 | - * |
|
| 50 | - * @param RequestInterface $request |
|
| 51 | - * @param ResponseInterface $response |
|
| 52 | - * @return ResponseInterface |
|
| 53 | - */ |
|
| 54 | - protected function processRequestStack(RequestInterface $request, ResponseInterface $response): ResponseInterface |
|
| 55 | - { |
|
| 56 | - $this->request = $request; |
|
| 57 | - $this->response = $response; |
|
| 58 | - if (! $this->response->requestTerminated()) { |
|
| 59 | - $this->response = $this->request_stack_app->handleRequest($this->request, $this->response); |
|
| 60 | - } |
|
| 61 | - return $this->response; |
|
| 62 | - } |
|
| 27 | + protected LoaderInterface $loader; |
|
| 28 | + |
|
| 29 | + protected RequestDecoratorInterface $request_stack_app; |
|
| 30 | + |
|
| 31 | + protected RequestInterface $request; |
|
| 32 | + |
|
| 33 | + protected ResponseInterface $response; |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @param RequestDecoratorInterface $request_stack_app |
|
| 38 | + * @param LoaderInterface $loader |
|
| 39 | + */ |
|
| 40 | + public function __construct(RequestDecoratorInterface $request_stack_app, LoaderInterface $loader) |
|
| 41 | + { |
|
| 42 | + $this->request_stack_app = $request_stack_app; |
|
| 43 | + $this->loader = $loader; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * process_request_stack |
|
| 49 | + * |
|
| 50 | + * @param RequestInterface $request |
|
| 51 | + * @param ResponseInterface $response |
|
| 52 | + * @return ResponseInterface |
|
| 53 | + */ |
|
| 54 | + protected function processRequestStack(RequestInterface $request, ResponseInterface $response): ResponseInterface |
|
| 55 | + { |
|
| 56 | + $this->request = $request; |
|
| 57 | + $this->response = $response; |
|
| 58 | + if (! $this->response->requestTerminated()) { |
|
| 59 | + $this->response = $this->request_stack_app->handleRequest($this->request, $this->response); |
|
| 60 | + } |
|
| 61 | + return $this->response; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | public function handle(CommandInterface $command) |
| 48 | 48 | { |
| 49 | 49 | /** @var UpdateRegistrationAndTransactionAfterChangeCommand $command */ |
| 50 | - if (! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) { |
|
| 50 | + if ( ! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) { |
|
| 51 | 51 | throw new InvalidEntityException( |
| 52 | 52 | get_class($command), |
| 53 | 53 | 'UpdateRegistrationAndTransactionAfterChangeCommand' |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class UpdateRegistrationAndTransactionAfterChangeCommandHandler extends CommandHandler |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var UpdateRegistrationService $update_registration_service |
|
| 22 | - */ |
|
| 23 | - private $update_registration_service; |
|
| 20 | + /** |
|
| 21 | + * @var UpdateRegistrationService $update_registration_service |
|
| 22 | + */ |
|
| 23 | + private $update_registration_service; |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Command constructor |
|
| 28 | - * |
|
| 29 | - * @param UpdateRegistrationService $update_registration_service |
|
| 30 | - */ |
|
| 31 | - public function __construct( |
|
| 32 | - UpdateRegistrationService $update_registration_service |
|
| 33 | - ) { |
|
| 34 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 35 | - $this->update_registration_service = $update_registration_service; |
|
| 36 | - } |
|
| 26 | + /** |
|
| 27 | + * Command constructor |
|
| 28 | + * |
|
| 29 | + * @param UpdateRegistrationService $update_registration_service |
|
| 30 | + */ |
|
| 31 | + public function __construct( |
|
| 32 | + UpdateRegistrationService $update_registration_service |
|
| 33 | + ) { |
|
| 34 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 35 | + $this->update_registration_service = $update_registration_service; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param CommandInterface|UpdateRegistrationAndTransactionAfterChangeCommand $command |
|
| 41 | - * @return boolean |
|
| 42 | - * @throws InvalidEntityException |
|
| 43 | - */ |
|
| 44 | - public function handle(CommandInterface $command) |
|
| 45 | - { |
|
| 46 | - /** @var UpdateRegistrationAndTransactionAfterChangeCommand $command */ |
|
| 47 | - if (! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) { |
|
| 48 | - throw new InvalidEntityException( |
|
| 49 | - get_class($command), |
|
| 50 | - 'UpdateRegistrationAndTransactionAfterChangeCommand' |
|
| 51 | - ); |
|
| 52 | - } |
|
| 53 | - return $this->update_registration_service->updateRegistrationAndTransaction($command->registration()); |
|
| 54 | - } |
|
| 39 | + /** |
|
| 40 | + * @param CommandInterface|UpdateRegistrationAndTransactionAfterChangeCommand $command |
|
| 41 | + * @return boolean |
|
| 42 | + * @throws InvalidEntityException |
|
| 43 | + */ |
|
| 44 | + public function handle(CommandInterface $command) |
|
| 45 | + { |
|
| 46 | + /** @var UpdateRegistrationAndTransactionAfterChangeCommand $command */ |
|
| 47 | + if (! $command instanceof UpdateRegistrationAndTransactionAfterChangeCommand) { |
|
| 48 | + throw new InvalidEntityException( |
|
| 49 | + get_class($command), |
|
| 50 | + 'UpdateRegistrationAndTransactionAfterChangeCommand' |
|
| 51 | + ); |
|
| 52 | + } |
|
| 53 | + return $this->update_registration_service->updateRegistrationAndTransaction($command->registration()); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | public function handle(CommandInterface $command) |
| 61 | 61 | { |
| 62 | 62 | /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
| 63 | - if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
| 63 | + if ( ! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
| 64 | 64 | throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
| 65 | 65 | } |
| 66 | 66 | $registration = $command->registration(); |
@@ -27,58 +27,58 @@ |
||
| 27 | 27 | */ |
| 28 | 28 | class CancelRegistrationAndTicketLineItemCommandHandler extends CommandHandler |
| 29 | 29 | { |
| 30 | - /** |
|
| 31 | - * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
| 32 | - */ |
|
| 33 | - private $cancel_ticket_line_item_service; |
|
| 30 | + /** |
|
| 31 | + * @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
| 32 | + */ |
|
| 33 | + private $cancel_ticket_line_item_service; |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Command constructor |
|
| 38 | - * |
|
| 39 | - * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
| 40 | - */ |
|
| 41 | - public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
| 42 | - { |
|
| 43 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 44 | - $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
| 45 | - } |
|
| 36 | + /** |
|
| 37 | + * Command constructor |
|
| 38 | + * |
|
| 39 | + * @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
| 40 | + */ |
|
| 41 | + public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
| 42 | + { |
|
| 43 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 44 | + $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * @param CommandInterface|CancelRegistrationAndTicketLineItemCommand $command |
|
| 50 | - * @return boolean |
|
| 51 | - * @throws DomainException |
|
| 52 | - * @throws EE_Error |
|
| 53 | - * @throws EntityNotFoundException |
|
| 54 | - * @throws InvalidDataTypeException |
|
| 55 | - * @throws InvalidEntityException |
|
| 56 | - * @throws InvalidInterfaceException |
|
| 57 | - * @throws InvalidArgumentException |
|
| 58 | - * @throws ReflectionException |
|
| 59 | - * @throws RuntimeException |
|
| 60 | - */ |
|
| 61 | - public function handle(CommandInterface $command) |
|
| 62 | - { |
|
| 63 | - /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
|
| 64 | - if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
| 65 | - throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
|
| 66 | - } |
|
| 67 | - $registration = $command->registration(); |
|
| 68 | - $this->cancel_ticket_line_item_service->forRegistration($registration); |
|
| 69 | - // cancel original registration |
|
| 70 | - $registration->set_status( |
|
| 71 | - RegStatus::CANCELLED, |
|
| 72 | - false, |
|
| 73 | - new Context( |
|
| 74 | - 'cancel-registration-and-ticket-line-item-command-handler', |
|
| 75 | - esc_html__( |
|
| 76 | - 'Executed when the registration status is updated via CancelRegistrationAndTicketLineItemCommandHandler.', |
|
| 77 | - 'event_espresso' |
|
| 78 | - ) |
|
| 79 | - ) |
|
| 80 | - ); |
|
| 81 | - $registration->save(); |
|
| 82 | - return true; |
|
| 83 | - } |
|
| 48 | + /** |
|
| 49 | + * @param CommandInterface|CancelRegistrationAndTicketLineItemCommand $command |
|
| 50 | + * @return boolean |
|
| 51 | + * @throws DomainException |
|
| 52 | + * @throws EE_Error |
|
| 53 | + * @throws EntityNotFoundException |
|
| 54 | + * @throws InvalidDataTypeException |
|
| 55 | + * @throws InvalidEntityException |
|
| 56 | + * @throws InvalidInterfaceException |
|
| 57 | + * @throws InvalidArgumentException |
|
| 58 | + * @throws ReflectionException |
|
| 59 | + * @throws RuntimeException |
|
| 60 | + */ |
|
| 61 | + public function handle(CommandInterface $command) |
|
| 62 | + { |
|
| 63 | + /** @var CancelRegistrationAndTicketLineItemCommand $command */ |
|
| 64 | + if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
| 65 | + throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
|
| 66 | + } |
|
| 67 | + $registration = $command->registration(); |
|
| 68 | + $this->cancel_ticket_line_item_service->forRegistration($registration); |
|
| 69 | + // cancel original registration |
|
| 70 | + $registration->set_status( |
|
| 71 | + RegStatus::CANCELLED, |
|
| 72 | + false, |
|
| 73 | + new Context( |
|
| 74 | + 'cancel-registration-and-ticket-line-item-command-handler', |
|
| 75 | + esc_html__( |
|
| 76 | + 'Executed when the registration status is updated via CancelRegistrationAndTicketLineItemCommandHandler.', |
|
| 77 | + 'event_espresso' |
|
| 78 | + ) |
|
| 79 | + ) |
|
| 80 | + ); |
|
| 81 | + $registration->save(); |
|
| 82 | + return true; |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | public function getCapCheck() |
| 58 | 58 | { |
| 59 | 59 | // need cap for non-AJAX admin requests |
| 60 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 60 | + if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 61 | 61 | // there's no specific caps for editing/creating transactions, |
| 62 | 62 | // so that's why we are using ee_edit_registrations |
| 63 | 63 | return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
@@ -20,60 +20,60 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var EE_Checkout $checkout |
|
| 25 | - */ |
|
| 26 | - protected $checkout; |
|
| 23 | + /** |
|
| 24 | + * @var EE_Checkout $checkout |
|
| 25 | + */ |
|
| 26 | + protected $checkout; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var array $transaction_details |
|
| 30 | - */ |
|
| 31 | - protected $transaction_details; |
|
| 28 | + /** |
|
| 29 | + * @var array $transaction_details |
|
| 30 | + */ |
|
| 31 | + protected $transaction_details; |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * CreateTransactionCommand constructor. |
|
| 36 | - * |
|
| 37 | - * @param EE_Checkout|null $checkout |
|
| 38 | - * @param array $transaction_details |
|
| 39 | - */ |
|
| 40 | - public function __construct(EE_Checkout $checkout = null, array $transaction_details = []) |
|
| 41 | - { |
|
| 42 | - $this->checkout = $checkout; |
|
| 43 | - $this->transaction_details = $transaction_details; |
|
| 44 | - } |
|
| 34 | + /** |
|
| 35 | + * CreateTransactionCommand constructor. |
|
| 36 | + * |
|
| 37 | + * @param EE_Checkout|null $checkout |
|
| 38 | + * @param array $transaction_details |
|
| 39 | + */ |
|
| 40 | + public function __construct(EE_Checkout $checkout = null, array $transaction_details = []) |
|
| 41 | + { |
|
| 42 | + $this->checkout = $checkout; |
|
| 43 | + $this->transaction_details = $transaction_details; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * @return CapCheckInterface |
|
| 49 | - * @throws InvalidDataTypeException |
|
| 50 | - */ |
|
| 51 | - public function getCapCheck() |
|
| 52 | - { |
|
| 53 | - // need cap for non-AJAX admin requests |
|
| 54 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 55 | - // there's no specific caps for editing/creating transactions, |
|
| 56 | - // so that's why we are using ee_edit_registrations |
|
| 57 | - return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
| 58 | - } |
|
| 59 | - return new PublicCapabilities('', 'create_new_transaction'); |
|
| 60 | - } |
|
| 47 | + /** |
|
| 48 | + * @return CapCheckInterface |
|
| 49 | + * @throws InvalidDataTypeException |
|
| 50 | + */ |
|
| 51 | + public function getCapCheck() |
|
| 52 | + { |
|
| 53 | + // need cap for non-AJAX admin requests |
|
| 54 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 55 | + // there's no specific caps for editing/creating transactions, |
|
| 56 | + // so that's why we are using ee_edit_registrations |
|
| 57 | + return new CapCheck('ee_edit_registrations', 'create_new_transaction'); |
|
| 58 | + } |
|
| 59 | + return new PublicCapabilities('', 'create_new_transaction'); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * @return EE_Checkout |
|
| 65 | - */ |
|
| 66 | - public function checkout() |
|
| 67 | - { |
|
| 68 | - return $this->checkout; |
|
| 69 | - } |
|
| 63 | + /** |
|
| 64 | + * @return EE_Checkout |
|
| 65 | + */ |
|
| 66 | + public function checkout() |
|
| 67 | + { |
|
| 68 | + return $this->checkout; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public function transactionDetails() |
|
| 76 | - { |
|
| 77 | - return $this->transaction_details; |
|
| 78 | - } |
|
| 72 | + /** |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public function transactionDetails() |
|
| 76 | + { |
|
| 77 | + return $this->transaction_details; |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -52,7 +52,7 @@ |
||
| 52 | 52 | public function handle(CommandInterface $command) |
| 53 | 53 | { |
| 54 | 54 | /** @var CreateTicketLineItemCommand $command */ |
| 55 | - if (! $command instanceof CreateTicketLineItemCommand) { |
|
| 55 | + if ( ! $command instanceof CreateTicketLineItemCommand) { |
|
| 56 | 56 | throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
| 57 | 57 | } |
| 58 | 58 | // create new line item for ticket |
@@ -20,42 +20,42 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class CreateTicketLineItemCommandHandler extends CommandHandler |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var CreateTicketLineItemService $factory |
|
| 25 | - */ |
|
| 26 | - private $factory; |
|
| 23 | + /** |
|
| 24 | + * @var CreateTicketLineItemService $factory |
|
| 25 | + */ |
|
| 26 | + private $factory; |
|
| 27 | 27 | |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Command constructor |
|
| 31 | - * |
|
| 32 | - * @param CreateTicketLineItemService $factory |
|
| 33 | - */ |
|
| 34 | - public function __construct(CreateTicketLineItemService $factory) |
|
| 35 | - { |
|
| 36 | - defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 37 | - $this->factory = $factory; |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * Command constructor |
|
| 31 | + * |
|
| 32 | + * @param CreateTicketLineItemService $factory |
|
| 33 | + */ |
|
| 34 | + public function __construct(CreateTicketLineItemService $factory) |
|
| 35 | + { |
|
| 36 | + defined('EVENT_ESPRESSO_VERSION') || exit; |
|
| 37 | + $this->factory = $factory; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @param CommandInterface|CreateTicketLineItemCommand $command |
|
| 43 | - * @return EE_Line_Item |
|
| 44 | - * @throws InvalidEntityException |
|
| 45 | - * @throws UnexpectedEntityException |
|
| 46 | - * @throws EE_Error |
|
| 47 | - */ |
|
| 48 | - public function handle(CommandInterface $command) |
|
| 49 | - { |
|
| 50 | - /** @var CreateTicketLineItemCommand $command */ |
|
| 51 | - if (! $command instanceof CreateTicketLineItemCommand) { |
|
| 52 | - throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
| 53 | - } |
|
| 54 | - // create new line item for ticket |
|
| 55 | - return $this->factory->create( |
|
| 56 | - $command->transaction(), |
|
| 57 | - $command->ticket(), |
|
| 58 | - $command->quantity() |
|
| 59 | - ); |
|
| 60 | - } |
|
| 41 | + /** |
|
| 42 | + * @param CommandInterface|CreateTicketLineItemCommand $command |
|
| 43 | + * @return EE_Line_Item |
|
| 44 | + * @throws InvalidEntityException |
|
| 45 | + * @throws UnexpectedEntityException |
|
| 46 | + * @throws EE_Error |
|
| 47 | + */ |
|
| 48 | + public function handle(CommandInterface $command) |
|
| 49 | + { |
|
| 50 | + /** @var CreateTicketLineItemCommand $command */ |
|
| 51 | + if (! $command instanceof CreateTicketLineItemCommand) { |
|
| 52 | + throw new InvalidEntityException(get_class($command), 'CreateTicketLineItemCommand'); |
|
| 53 | + } |
|
| 54 | + // create new line item for ticket |
|
| 55 | + return $this->factory->create( |
|
| 56 | + $command->transaction(), |
|
| 57 | + $command->ticket(), |
|
| 58 | + $command->quantity() |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | 61 | } |