@@ -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; |
@@ -11,91 +11,91 @@ |
||
| 11 | 11 | class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @var WP_User |
|
| 16 | - */ |
|
| 17 | - protected $_wp_user_obj; |
|
| 14 | + /** |
|
| 15 | + * @var WP_User |
|
| 16 | + */ |
|
| 17 | + protected $_wp_user_obj; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @param array $props_n_values |
|
| 21 | - * @return EE_WP_User|mixed |
|
| 22 | - */ |
|
| 23 | - public static function new_instance($props_n_values = array()) |
|
| 24 | - { |
|
| 25 | - $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 26 | - return $has_object ? $has_object : new self($props_n_values); |
|
| 27 | - } |
|
| 19 | + /** |
|
| 20 | + * @param array $props_n_values |
|
| 21 | + * @return EE_WP_User|mixed |
|
| 22 | + */ |
|
| 23 | + public static function new_instance($props_n_values = array()) |
|
| 24 | + { |
|
| 25 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
| 26 | + return $has_object ? $has_object : new self($props_n_values); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @param array $props_n_values |
|
| 32 | - * @return EE_WP_User |
|
| 33 | - */ |
|
| 34 | - public static function new_instance_from_db($props_n_values = array()) |
|
| 35 | - { |
|
| 36 | - return new self($props_n_values, true); |
|
| 37 | - } |
|
| 30 | + /** |
|
| 31 | + * @param array $props_n_values |
|
| 32 | + * @return EE_WP_User |
|
| 33 | + */ |
|
| 34 | + public static function new_instance_from_db($props_n_values = array()) |
|
| 35 | + { |
|
| 36 | + return new self($props_n_values, true); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Return a normal WP_User object (caches the object for future calls) |
|
| 41 | - * |
|
| 42 | - * @return WP_User |
|
| 43 | - */ |
|
| 44 | - public function wp_user_obj() |
|
| 45 | - { |
|
| 46 | - if (! $this->_wp_user_obj) { |
|
| 47 | - $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 48 | - } |
|
| 49 | - return $this->_wp_user_obj; |
|
| 50 | - } |
|
| 39 | + /** |
|
| 40 | + * Return a normal WP_User object (caches the object for future calls) |
|
| 41 | + * |
|
| 42 | + * @return WP_User |
|
| 43 | + */ |
|
| 44 | + public function wp_user_obj() |
|
| 45 | + { |
|
| 46 | + if (! $this->_wp_user_obj) { |
|
| 47 | + $this->_wp_user_obj = get_user_by('ID', $this->ID()); |
|
| 48 | + } |
|
| 49 | + return $this->_wp_user_obj; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Return the link to the admin details for the object. |
|
| 54 | - * |
|
| 55 | - * @return string |
|
| 56 | - */ |
|
| 57 | - public function get_admin_details_link() |
|
| 58 | - { |
|
| 59 | - return $this->get_admin_edit_link(); |
|
| 60 | - } |
|
| 52 | + /** |
|
| 53 | + * Return the link to the admin details for the object. |
|
| 54 | + * |
|
| 55 | + * @return string |
|
| 56 | + */ |
|
| 57 | + public function get_admin_details_link() |
|
| 58 | + { |
|
| 59 | + return $this->get_admin_edit_link(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 64 | - * |
|
| 65 | - * @return string |
|
| 66 | - */ |
|
| 67 | - public function get_admin_edit_link() |
|
| 68 | - { |
|
| 69 | - return esc_url( |
|
| 70 | - add_query_arg( |
|
| 71 | - 'wp_http_referer', |
|
| 72 | - urlencode( |
|
| 73 | - wp_unslash( |
|
| 74 | - $_SERVER['REQUEST_URI'] |
|
| 75 | - ) |
|
| 76 | - ), |
|
| 77 | - get_edit_user_link($this->ID()) |
|
| 78 | - ) |
|
| 79 | - ); |
|
| 80 | - } |
|
| 62 | + /** |
|
| 63 | + * Returns the link to the editor for the object. Sometimes this is the same as the details. |
|
| 64 | + * |
|
| 65 | + * @return string |
|
| 66 | + */ |
|
| 67 | + public function get_admin_edit_link() |
|
| 68 | + { |
|
| 69 | + return esc_url( |
|
| 70 | + add_query_arg( |
|
| 71 | + 'wp_http_referer', |
|
| 72 | + urlencode( |
|
| 73 | + wp_unslash( |
|
| 74 | + $_SERVER['REQUEST_URI'] |
|
| 75 | + ) |
|
| 76 | + ), |
|
| 77 | + get_edit_user_link($this->ID()) |
|
| 78 | + ) |
|
| 79 | + ); |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Returns the link to a settings page for the object. |
|
| 84 | - * |
|
| 85 | - * @return string |
|
| 86 | - */ |
|
| 87 | - public function get_admin_settings_link() |
|
| 88 | - { |
|
| 89 | - return $this->get_admin_edit_link(); |
|
| 90 | - } |
|
| 82 | + /** |
|
| 83 | + * Returns the link to a settings page for the object. |
|
| 84 | + * |
|
| 85 | + * @return string |
|
| 86 | + */ |
|
| 87 | + public function get_admin_settings_link() |
|
| 88 | + { |
|
| 89 | + return $this->get_admin_edit_link(); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 94 | - * |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - public function get_admin_overview_link() |
|
| 98 | - { |
|
| 99 | - return admin_url('users.php'); |
|
| 100 | - } |
|
| 92 | + /** |
|
| 93 | + * Returns the link to the "overview" for the object (typically the "list table" view). |
|
| 94 | + * |
|
| 95 | + * @return string |
|
| 96 | + */ |
|
| 97 | + public function get_admin_overview_link() |
|
| 98 | + { |
|
| 99 | + return admin_url('users.php'); |
|
| 100 | + } |
|
| 101 | 101 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * this method instantiates modules and calls the method that was defined when the route was registered |
| 183 | 183 | * |
| 184 | 184 | * @param string $module_name |
| 185 | - * @return EED_Module|object|null |
|
| 185 | + * @return null|EED_Module |
|
| 186 | 186 | * @throws ReflectionException |
| 187 | 187 | */ |
| 188 | 188 | public static function module_factory($module_name) |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | - * @param $current_route |
|
| 255 | + * @param string $current_route |
|
| 256 | 256 | * @return string |
| 257 | 257 | */ |
| 258 | 258 | public function get_view($current_route) |
@@ -15,255 +15,255 @@ |
||
| 15 | 15 | final class EE_Module_Request_Router implements InterminableInterface |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var EE_Request $request |
|
| 20 | - */ |
|
| 21 | - private $request; |
|
| 18 | + /** |
|
| 19 | + * @var EE_Request $request |
|
| 20 | + */ |
|
| 21 | + private $request; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var array $_previous_routes |
|
| 25 | - */ |
|
| 26 | - private static $_previous_routes = array(); |
|
| 23 | + /** |
|
| 24 | + * @var array $_previous_routes |
|
| 25 | + */ |
|
| 26 | + private static $_previous_routes = array(); |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var WP_Query $WP_Query |
|
| 30 | - */ |
|
| 31 | - public $WP_Query; |
|
| 28 | + /** |
|
| 29 | + * @var WP_Query $WP_Query |
|
| 30 | + */ |
|
| 31 | + public $WP_Query; |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * EE_Module_Request_Router constructor. |
|
| 36 | - * |
|
| 37 | - * @param EE_Request $request |
|
| 38 | - */ |
|
| 39 | - public function __construct(EE_Request $request) |
|
| 40 | - { |
|
| 41 | - $this->request = $request; |
|
| 42 | - } |
|
| 34 | + /** |
|
| 35 | + * EE_Module_Request_Router constructor. |
|
| 36 | + * |
|
| 37 | + * @param EE_Request $request |
|
| 38 | + */ |
|
| 39 | + public function __construct(EE_Request $request) |
|
| 40 | + { |
|
| 41 | + $this->request = $request; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
| 47 | - * on subsequent calls to this method, |
|
| 48 | - * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
| 49 | - * and checks if the last called route has any forwarding routes registered for it |
|
| 50 | - * |
|
| 51 | - * @param WP_Query $WP_Query |
|
| 52 | - * @return NULL|string |
|
| 53 | - * @throws EE_Error |
|
| 54 | - * @throws ReflectionException |
|
| 55 | - */ |
|
| 56 | - public function get_route(WP_Query $WP_Query) |
|
| 57 | - { |
|
| 58 | - $this->WP_Query = $WP_Query; |
|
| 59 | - // assume this if first route being called |
|
| 60 | - $previous_route = false; |
|
| 61 | - // but is it really ??? |
|
| 62 | - if (! empty(self::$_previous_routes)) { |
|
| 63 | - // get last run route |
|
| 64 | - $previous_routes = array_values(self::$_previous_routes); |
|
| 65 | - $previous_route = array_pop($previous_routes); |
|
| 66 | - } |
|
| 67 | - // has another route already been run ? |
|
| 68 | - if ($previous_route) { |
|
| 69 | - // check if forwarding has been set |
|
| 70 | - $current_route = $this->get_forward($previous_route); |
|
| 71 | - try { |
|
| 72 | - // check for recursive forwarding |
|
| 73 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
| 74 | - throw new EE_Error( |
|
| 75 | - sprintf( |
|
| 76 | - __( |
|
| 77 | - 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
| 78 | - 'event_espresso' |
|
| 79 | - ), |
|
| 80 | - $current_route |
|
| 81 | - ) |
|
| 82 | - ); |
|
| 83 | - } |
|
| 84 | - } catch (EE_Error $e) { |
|
| 85 | - $e->get_error(); |
|
| 86 | - return null; |
|
| 87 | - } |
|
| 88 | - } else { |
|
| 89 | - // first route called |
|
| 90 | - $current_route = null; |
|
| 91 | - // grab all routes |
|
| 92 | - $routes = EE_Config::get_routes(); |
|
| 93 | - foreach ($routes as $key => $route) { |
|
| 94 | - // first determine if route key uses w?ldc*rds |
|
| 95 | - $uses_wildcards = strpos($key, '?') !== false |
|
| 96 | - || strpos($key, '*') !== false; |
|
| 97 | - // check request for module route |
|
| 98 | - $route_found = $uses_wildcards |
|
| 99 | - ? $this->request->matches($key) |
|
| 100 | - : $this->request->is_set($key); |
|
| 101 | - if ($route_found) { |
|
| 102 | - $current_route = $uses_wildcards |
|
| 103 | - ? $this->request->getMatch($key) |
|
| 104 | - : $this->request->get($key); |
|
| 105 | - $current_route = sanitize_text_field($current_route); |
|
| 106 | - if ($current_route) { |
|
| 107 | - $current_route = array($key, $current_route); |
|
| 108 | - break; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - // sorry, but I can't read what you route ! |
|
| 114 | - if (empty($current_route)) { |
|
| 115 | - return null; |
|
| 116 | - } |
|
| 117 | - // add route to previous routes array |
|
| 118 | - self::$_previous_routes[] = $current_route; |
|
| 119 | - return $current_route; |
|
| 120 | - } |
|
| 45 | + /** |
|
| 46 | + * on the first call to this method, it checks the EE_Request_Handler for a "route" |
|
| 47 | + * on subsequent calls to this method, |
|
| 48 | + * instead of checking the EE_Request_Handler for a route, it checks the previous routes array, |
|
| 49 | + * and checks if the last called route has any forwarding routes registered for it |
|
| 50 | + * |
|
| 51 | + * @param WP_Query $WP_Query |
|
| 52 | + * @return NULL|string |
|
| 53 | + * @throws EE_Error |
|
| 54 | + * @throws ReflectionException |
|
| 55 | + */ |
|
| 56 | + public function get_route(WP_Query $WP_Query) |
|
| 57 | + { |
|
| 58 | + $this->WP_Query = $WP_Query; |
|
| 59 | + // assume this if first route being called |
|
| 60 | + $previous_route = false; |
|
| 61 | + // but is it really ??? |
|
| 62 | + if (! empty(self::$_previous_routes)) { |
|
| 63 | + // get last run route |
|
| 64 | + $previous_routes = array_values(self::$_previous_routes); |
|
| 65 | + $previous_route = array_pop($previous_routes); |
|
| 66 | + } |
|
| 67 | + // has another route already been run ? |
|
| 68 | + if ($previous_route) { |
|
| 69 | + // check if forwarding has been set |
|
| 70 | + $current_route = $this->get_forward($previous_route); |
|
| 71 | + try { |
|
| 72 | + // check for recursive forwarding |
|
| 73 | + if (isset(self::$_previous_routes[ $current_route ])) { |
|
| 74 | + throw new EE_Error( |
|
| 75 | + sprintf( |
|
| 76 | + __( |
|
| 77 | + 'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.', |
|
| 78 | + 'event_espresso' |
|
| 79 | + ), |
|
| 80 | + $current_route |
|
| 81 | + ) |
|
| 82 | + ); |
|
| 83 | + } |
|
| 84 | + } catch (EE_Error $e) { |
|
| 85 | + $e->get_error(); |
|
| 86 | + return null; |
|
| 87 | + } |
|
| 88 | + } else { |
|
| 89 | + // first route called |
|
| 90 | + $current_route = null; |
|
| 91 | + // grab all routes |
|
| 92 | + $routes = EE_Config::get_routes(); |
|
| 93 | + foreach ($routes as $key => $route) { |
|
| 94 | + // first determine if route key uses w?ldc*rds |
|
| 95 | + $uses_wildcards = strpos($key, '?') !== false |
|
| 96 | + || strpos($key, '*') !== false; |
|
| 97 | + // check request for module route |
|
| 98 | + $route_found = $uses_wildcards |
|
| 99 | + ? $this->request->matches($key) |
|
| 100 | + : $this->request->is_set($key); |
|
| 101 | + if ($route_found) { |
|
| 102 | + $current_route = $uses_wildcards |
|
| 103 | + ? $this->request->getMatch($key) |
|
| 104 | + : $this->request->get($key); |
|
| 105 | + $current_route = sanitize_text_field($current_route); |
|
| 106 | + if ($current_route) { |
|
| 107 | + $current_route = array($key, $current_route); |
|
| 108 | + break; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + // sorry, but I can't read what you route ! |
|
| 114 | + if (empty($current_route)) { |
|
| 115 | + return null; |
|
| 116 | + } |
|
| 117 | + // add route to previous routes array |
|
| 118 | + self::$_previous_routes[] = $current_route; |
|
| 119 | + return $current_route; |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * this method simply takes a valid route, and resolves what module class method the route points to |
|
| 125 | - * |
|
| 126 | - * @param string $key |
|
| 127 | - * @param string $current_route |
|
| 128 | - * @return mixed EED_Module | boolean |
|
| 129 | - * @throws EE_Error |
|
| 130 | - * @throws ReflectionException |
|
| 131 | - */ |
|
| 132 | - public function resolve_route($key, $current_route) |
|
| 133 | - { |
|
| 134 | - // get module method that route has been mapped to |
|
| 135 | - $module_method = EE_Config::get_route($current_route, $key); |
|
| 136 | - // verify result was returned |
|
| 137 | - if (empty($module_method)) { |
|
| 138 | - $msg = sprintf( |
|
| 139 | - __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
| 140 | - $current_route |
|
| 141 | - ); |
|
| 142 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 143 | - return false; |
|
| 144 | - } |
|
| 145 | - // verify that result is an array |
|
| 146 | - if (! is_array($module_method)) { |
|
| 147 | - $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 148 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 149 | - return false; |
|
| 150 | - } |
|
| 151 | - // grab module name |
|
| 152 | - $module_name = $module_method[0]; |
|
| 153 | - // verify that a class method was registered properly |
|
| 154 | - if (! isset($module_method[1])) { |
|
| 155 | - $msg = sprintf( |
|
| 156 | - __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
| 157 | - $current_route |
|
| 158 | - ); |
|
| 159 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 160 | - return false; |
|
| 161 | - } |
|
| 162 | - // grab method |
|
| 163 | - $method = $module_method[1]; |
|
| 164 | - // verify that class exists |
|
| 165 | - if (! class_exists($module_name)) { |
|
| 166 | - $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
| 167 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 168 | - return false; |
|
| 169 | - } |
|
| 170 | - // verify that method exists |
|
| 171 | - if (! method_exists($module_name, $method)) { |
|
| 172 | - $msg = sprintf( |
|
| 173 | - __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
| 174 | - $method, |
|
| 175 | - $current_route |
|
| 176 | - ); |
|
| 177 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 178 | - return false; |
|
| 179 | - } |
|
| 180 | - // instantiate module and call route method |
|
| 181 | - return $this->_module_router($module_name, $method); |
|
| 182 | - } |
|
| 123 | + /** |
|
| 124 | + * this method simply takes a valid route, and resolves what module class method the route points to |
|
| 125 | + * |
|
| 126 | + * @param string $key |
|
| 127 | + * @param string $current_route |
|
| 128 | + * @return mixed EED_Module | boolean |
|
| 129 | + * @throws EE_Error |
|
| 130 | + * @throws ReflectionException |
|
| 131 | + */ |
|
| 132 | + public function resolve_route($key, $current_route) |
|
| 133 | + { |
|
| 134 | + // get module method that route has been mapped to |
|
| 135 | + $module_method = EE_Config::get_route($current_route, $key); |
|
| 136 | + // verify result was returned |
|
| 137 | + if (empty($module_method)) { |
|
| 138 | + $msg = sprintf( |
|
| 139 | + __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'), |
|
| 140 | + $current_route |
|
| 141 | + ); |
|
| 142 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 145 | + // verify that result is an array |
|
| 146 | + if (! is_array($module_method)) { |
|
| 147 | + $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
|
| 148 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 149 | + return false; |
|
| 150 | + } |
|
| 151 | + // grab module name |
|
| 152 | + $module_name = $module_method[0]; |
|
| 153 | + // verify that a class method was registered properly |
|
| 154 | + if (! isset($module_method[1])) { |
|
| 155 | + $msg = sprintf( |
|
| 156 | + __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
|
| 157 | + $current_route |
|
| 158 | + ); |
|
| 159 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 160 | + return false; |
|
| 161 | + } |
|
| 162 | + // grab method |
|
| 163 | + $method = $module_method[1]; |
|
| 164 | + // verify that class exists |
|
| 165 | + if (! class_exists($module_name)) { |
|
| 166 | + $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
|
| 167 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 168 | + return false; |
|
| 169 | + } |
|
| 170 | + // verify that method exists |
|
| 171 | + if (! method_exists($module_name, $method)) { |
|
| 172 | + $msg = sprintf( |
|
| 173 | + __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
|
| 174 | + $method, |
|
| 175 | + $current_route |
|
| 176 | + ); |
|
| 177 | + EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 178 | + return false; |
|
| 179 | + } |
|
| 180 | + // instantiate module and call route method |
|
| 181 | + return $this->_module_router($module_name, $method); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 187 | - * |
|
| 188 | - * @param string $module_name |
|
| 189 | - * @return EED_Module|object|null |
|
| 190 | - * @throws ReflectionException |
|
| 191 | - */ |
|
| 192 | - public static function module_factory($module_name) |
|
| 193 | - { |
|
| 194 | - if ($module_name === 'EED_Module') { |
|
| 195 | - EE_Error::add_error( |
|
| 196 | - sprintf( |
|
| 197 | - __( |
|
| 198 | - 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
| 199 | - 'event_espresso' |
|
| 200 | - ), |
|
| 201 | - $module_name |
|
| 202 | - ), |
|
| 203 | - __FILE__, |
|
| 204 | - __FUNCTION__, |
|
| 205 | - __LINE__ |
|
| 206 | - ); |
|
| 207 | - return null; |
|
| 208 | - } |
|
| 209 | - // instantiate module class |
|
| 210 | - $module = new $module_name(); |
|
| 211 | - // ensure that class is actually a module |
|
| 212 | - if (! $module instanceof EED_Module) { |
|
| 213 | - EE_Error::add_error( |
|
| 214 | - sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
| 215 | - __FILE__, |
|
| 216 | - __FUNCTION__, |
|
| 217 | - __LINE__ |
|
| 218 | - ); |
|
| 219 | - return null; |
|
| 220 | - } |
|
| 221 | - return $module; |
|
| 222 | - } |
|
| 185 | + /** |
|
| 186 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 187 | + * |
|
| 188 | + * @param string $module_name |
|
| 189 | + * @return EED_Module|object|null |
|
| 190 | + * @throws ReflectionException |
|
| 191 | + */ |
|
| 192 | + public static function module_factory($module_name) |
|
| 193 | + { |
|
| 194 | + if ($module_name === 'EED_Module') { |
|
| 195 | + EE_Error::add_error( |
|
| 196 | + sprintf( |
|
| 197 | + __( |
|
| 198 | + 'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.', |
|
| 199 | + 'event_espresso' |
|
| 200 | + ), |
|
| 201 | + $module_name |
|
| 202 | + ), |
|
| 203 | + __FILE__, |
|
| 204 | + __FUNCTION__, |
|
| 205 | + __LINE__ |
|
| 206 | + ); |
|
| 207 | + return null; |
|
| 208 | + } |
|
| 209 | + // instantiate module class |
|
| 210 | + $module = new $module_name(); |
|
| 211 | + // ensure that class is actually a module |
|
| 212 | + if (! $module instanceof EED_Module) { |
|
| 213 | + EE_Error::add_error( |
|
| 214 | + sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
|
| 215 | + __FILE__, |
|
| 216 | + __FUNCTION__, |
|
| 217 | + __LINE__ |
|
| 218 | + ); |
|
| 219 | + return null; |
|
| 220 | + } |
|
| 221 | + return $module; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | 224 | |
| 225 | - /** |
|
| 226 | - * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 227 | - * |
|
| 228 | - * @param string $module_name |
|
| 229 | - * @param string $method |
|
| 230 | - * @return EED_Module|null |
|
| 231 | - * @throws EE_Error |
|
| 232 | - * @throws ReflectionException |
|
| 233 | - */ |
|
| 234 | - private function _module_router($module_name, $method) |
|
| 235 | - { |
|
| 236 | - // instantiate module class |
|
| 237 | - $module = EE_Module_Request_Router::module_factory($module_name); |
|
| 238 | - if ($module instanceof EED_Module) { |
|
| 239 | - // and call whatever action the route was for |
|
| 240 | - try { |
|
| 241 | - call_user_func(array($module, $method), $this->WP_Query); |
|
| 242 | - } catch (EE_Error $e) { |
|
| 243 | - $e->get_error(); |
|
| 244 | - return null; |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - return $module; |
|
| 248 | - } |
|
| 225 | + /** |
|
| 226 | + * this method instantiates modules and calls the method that was defined when the route was registered |
|
| 227 | + * |
|
| 228 | + * @param string $module_name |
|
| 229 | + * @param string $method |
|
| 230 | + * @return EED_Module|null |
|
| 231 | + * @throws EE_Error |
|
| 232 | + * @throws ReflectionException |
|
| 233 | + */ |
|
| 234 | + private function _module_router($module_name, $method) |
|
| 235 | + { |
|
| 236 | + // instantiate module class |
|
| 237 | + $module = EE_Module_Request_Router::module_factory($module_name); |
|
| 238 | + if ($module instanceof EED_Module) { |
|
| 239 | + // and call whatever action the route was for |
|
| 240 | + try { |
|
| 241 | + call_user_func(array($module, $method), $this->WP_Query); |
|
| 242 | + } catch (EE_Error $e) { |
|
| 243 | + $e->get_error(); |
|
| 244 | + return null; |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + return $module; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | - /** |
|
| 252 | - * @param $current_route |
|
| 253 | - * @return string |
|
| 254 | - */ |
|
| 255 | - public function get_forward($current_route) |
|
| 256 | - { |
|
| 257 | - return EE_Config::get_forward($current_route); |
|
| 258 | - } |
|
| 251 | + /** |
|
| 252 | + * @param $current_route |
|
| 253 | + * @return string |
|
| 254 | + */ |
|
| 255 | + public function get_forward($current_route) |
|
| 256 | + { |
|
| 257 | + return EE_Config::get_forward($current_route); |
|
| 258 | + } |
|
| 259 | 259 | |
| 260 | 260 | |
| 261 | - /** |
|
| 262 | - * @param $current_route |
|
| 263 | - * @return string |
|
| 264 | - */ |
|
| 265 | - public function get_view($current_route) |
|
| 266 | - { |
|
| 267 | - return EE_Config::get_view($current_route); |
|
| 268 | - } |
|
| 261 | + /** |
|
| 262 | + * @param $current_route |
|
| 263 | + * @return string |
|
| 264 | + */ |
|
| 265 | + public function get_view($current_route) |
|
| 266 | + { |
|
| 267 | + return EE_Config::get_view($current_route); |
|
| 268 | + } |
|
| 269 | 269 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | // assume this if first route being called |
| 60 | 60 | $previous_route = false; |
| 61 | 61 | // but is it really ??? |
| 62 | - if (! empty(self::$_previous_routes)) { |
|
| 62 | + if ( ! empty(self::$_previous_routes)) { |
|
| 63 | 63 | // get last run route |
| 64 | 64 | $previous_routes = array_values(self::$_previous_routes); |
| 65 | 65 | $previous_route = array_pop($previous_routes); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $current_route = $this->get_forward($previous_route); |
| 71 | 71 | try { |
| 72 | 72 | // check for recursive forwarding |
| 73 | - if (isset(self::$_previous_routes[ $current_route ])) { |
|
| 73 | + if (isset(self::$_previous_routes[$current_route])) { |
|
| 74 | 74 | throw new EE_Error( |
| 75 | 75 | sprintf( |
| 76 | 76 | __( |
@@ -143,38 +143,38 @@ discard block |
||
| 143 | 143 | return false; |
| 144 | 144 | } |
| 145 | 145 | // verify that result is an array |
| 146 | - if (! is_array($module_method)) { |
|
| 146 | + if ( ! is_array($module_method)) { |
|
| 147 | 147 | $msg = sprintf(__('The %s route has not been properly registered.', 'event_espresso'), $current_route); |
| 148 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 148 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | // grab module name |
| 152 | 152 | $module_name = $module_method[0]; |
| 153 | 153 | // verify that a class method was registered properly |
| 154 | - if (! isset($module_method[1])) { |
|
| 154 | + if ( ! isset($module_method[1])) { |
|
| 155 | 155 | $msg = sprintf( |
| 156 | 156 | __('A class method for the %s route has not been properly registered.', 'event_espresso'), |
| 157 | 157 | $current_route |
| 158 | 158 | ); |
| 159 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 159 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 160 | 160 | return false; |
| 161 | 161 | } |
| 162 | 162 | // grab method |
| 163 | 163 | $method = $module_method[1]; |
| 164 | 164 | // verify that class exists |
| 165 | - if (! class_exists($module_name)) { |
|
| 165 | + if ( ! class_exists($module_name)) { |
|
| 166 | 166 | $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name); |
| 167 | 167 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | 170 | // verify that method exists |
| 171 | - if (! method_exists($module_name, $method)) { |
|
| 171 | + if ( ! method_exists($module_name, $method)) { |
|
| 172 | 172 | $msg = sprintf( |
| 173 | 173 | __('The class method %s for the %s route is in invalid.', 'event_espresso'), |
| 174 | 174 | $method, |
| 175 | 175 | $current_route |
| 176 | 176 | ); |
| 177 | - EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 177 | + EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 178 | 178 | return false; |
| 179 | 179 | } |
| 180 | 180 | // instantiate module and call route method |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | // instantiate module class |
| 210 | 210 | $module = new $module_name(); |
| 211 | 211 | // ensure that class is actually a module |
| 212 | - if (! $module instanceof EED_Module) { |
|
| 212 | + if ( ! $module instanceof EED_Module) { |
|
| 213 | 213 | EE_Error::add_error( |
| 214 | 214 | sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name), |
| 215 | 215 | __FILE__, |
@@ -9,24 +9,24 @@ |
||
| 9 | 9 | interface EEI_Request_Decorator |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * converts a Request to a Response |
|
| 14 | - * can perform their logic either before or after the core application has run like so: |
|
| 15 | - * public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 16 | - * $this->request = $request; |
|
| 17 | - * $this->response = $response; |
|
| 18 | - * // logic performed BEFORE core app has run |
|
| 19 | - * $this->process_request_stack( $this->request, $this->response ); |
|
| 20 | - * // logic performed AFTER core app has run |
|
| 21 | - * return $response; |
|
| 22 | - * } |
|
| 23 | - * |
|
| 24 | - * @deprecated 4.9.53 |
|
| 25 | - * @param EE_Request $request |
|
| 26 | - * @param EE_Response $response |
|
| 27 | - * @return EE_Response |
|
| 28 | - */ |
|
| 29 | - public function handle_request(EE_Request $request, EE_Response $response); |
|
| 12 | + /** |
|
| 13 | + * converts a Request to a Response |
|
| 14 | + * can perform their logic either before or after the core application has run like so: |
|
| 15 | + * public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 16 | + * $this->request = $request; |
|
| 17 | + * $this->response = $response; |
|
| 18 | + * // logic performed BEFORE core app has run |
|
| 19 | + * $this->process_request_stack( $this->request, $this->response ); |
|
| 20 | + * // logic performed AFTER core app has run |
|
| 21 | + * return $response; |
|
| 22 | + * } |
|
| 23 | + * |
|
| 24 | + * @deprecated 4.9.53 |
|
| 25 | + * @param EE_Request $request |
|
| 26 | + * @param EE_Response $response |
|
| 27 | + * @return EE_Response |
|
| 28 | + */ |
|
| 29 | + public function handle_request(EE_Request $request, EE_Response $response); |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | } |
@@ -15,125 +15,125 @@ |
||
| 15 | 15 | interface LegacyRequestInterface |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @return array |
|
| 20 | - */ |
|
| 21 | - public function get_params(); |
|
| 18 | + /** |
|
| 19 | + * @return array |
|
| 20 | + */ |
|
| 21 | + public function get_params(); |
|
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @return array |
|
| 26 | - */ |
|
| 27 | - public function post_params(); |
|
| 24 | + /** |
|
| 25 | + * @return array |
|
| 26 | + */ |
|
| 27 | + public function post_params(); |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @return array |
|
| 32 | - */ |
|
| 33 | - public function cookie_params(); |
|
| 30 | + /** |
|
| 31 | + * @return array |
|
| 32 | + */ |
|
| 33 | + public function cookie_params(); |
|
| 34 | 34 | |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @return array |
|
| 38 | - */ |
|
| 39 | - public function server_params(); |
|
| 36 | + /** |
|
| 37 | + * @return array |
|
| 38 | + */ |
|
| 39 | + public function server_params(); |
|
| 40 | 40 | |
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * returns contents of $_REQUEST |
|
| 44 | - * |
|
| 45 | - * @return array |
|
| 46 | - */ |
|
| 47 | - public function params(); |
|
| 42 | + /** |
|
| 43 | + * returns contents of $_REQUEST |
|
| 44 | + * |
|
| 45 | + * @return array |
|
| 46 | + */ |
|
| 47 | + public function params(); |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param $key |
|
| 52 | - * @param $value |
|
| 53 | - * @param bool $override_ee |
|
| 54 | - * @return void |
|
| 55 | - */ |
|
| 56 | - public function set($key, $value, $override_ee = false); |
|
| 50 | + /** |
|
| 51 | + * @param $key |
|
| 52 | + * @param $value |
|
| 53 | + * @param bool $override_ee |
|
| 54 | + * @return void |
|
| 55 | + */ |
|
| 56 | + public function set($key, $value, $override_ee = false); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * returns the value for a request param if the given key exists |
|
| 61 | - * |
|
| 62 | - * @param $key |
|
| 63 | - * @param null $default |
|
| 64 | - * @return mixed |
|
| 65 | - */ |
|
| 66 | - public function get($key, $default = null); |
|
| 59 | + /** |
|
| 60 | + * returns the value for a request param if the given key exists |
|
| 61 | + * |
|
| 62 | + * @param $key |
|
| 63 | + * @param null $default |
|
| 64 | + * @return mixed |
|
| 65 | + */ |
|
| 66 | + public function get($key, $default = null); |
|
| 67 | 67 | |
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * check if param exists |
|
| 71 | - * |
|
| 72 | - * @param $key |
|
| 73 | - * @return bool |
|
| 74 | - */ |
|
| 75 | - public function is_set($key); |
|
| 69 | + /** |
|
| 70 | + * check if param exists |
|
| 71 | + * |
|
| 72 | + * @param $key |
|
| 73 | + * @return bool |
|
| 74 | + */ |
|
| 75 | + public function is_set($key); |
|
| 76 | 76 | |
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * remove param |
|
| 80 | - * |
|
| 81 | - * @param $key |
|
| 82 | - * @param bool $unset_from_global_too |
|
| 83 | - */ |
|
| 84 | - public function un_set($key, $unset_from_global_too = false); |
|
| 78 | + /** |
|
| 79 | + * remove param |
|
| 80 | + * |
|
| 81 | + * @param $key |
|
| 82 | + * @param bool $unset_from_global_too |
|
| 83 | + */ |
|
| 84 | + public function un_set($key, $unset_from_global_too = false); |
|
| 85 | 85 | |
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @return string |
|
| 89 | - */ |
|
| 90 | - public function ip_address(); |
|
| 87 | + /** |
|
| 88 | + * @return string |
|
| 89 | + */ |
|
| 90 | + public function ip_address(); |
|
| 91 | 91 | |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * @return bool |
|
| 95 | - */ |
|
| 96 | - public function isAdmin(); |
|
| 93 | + /** |
|
| 94 | + * @return bool |
|
| 95 | + */ |
|
| 96 | + public function isAdmin(); |
|
| 97 | 97 | |
| 98 | 98 | |
| 99 | - /** |
|
| 100 | - * @return mixed |
|
| 101 | - */ |
|
| 102 | - public function isAjax(); |
|
| 99 | + /** |
|
| 100 | + * @return mixed |
|
| 101 | + */ |
|
| 102 | + public function isAjax(); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * @return mixed |
|
| 107 | - */ |
|
| 108 | - public function isFrontAjax(); |
|
| 105 | + /** |
|
| 106 | + * @return mixed |
|
| 107 | + */ |
|
| 108 | + public function isFrontAjax(); |
|
| 109 | 109 | |
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * @return mixed|string |
|
| 113 | - */ |
|
| 114 | - public function requestUri(); |
|
| 111 | + /** |
|
| 112 | + * @return mixed|string |
|
| 113 | + */ |
|
| 114 | + public function requestUri(); |
|
| 115 | 115 | |
| 116 | 116 | |
| 117 | - /** |
|
| 118 | - * @return string |
|
| 119 | - */ |
|
| 120 | - public function userAgent(); |
|
| 117 | + /** |
|
| 118 | + * @return string |
|
| 119 | + */ |
|
| 120 | + public function userAgent(); |
|
| 121 | 121 | |
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * @param string $user_agent |
|
| 125 | - */ |
|
| 126 | - public function setUserAgent($user_agent = ''); |
|
| 123 | + /** |
|
| 124 | + * @param string $user_agent |
|
| 125 | + */ |
|
| 126 | + public function setUserAgent($user_agent = ''); |
|
| 127 | 127 | |
| 128 | 128 | |
| 129 | - /** |
|
| 130 | - * @return bool |
|
| 131 | - */ |
|
| 132 | - public function isBot(); |
|
| 129 | + /** |
|
| 130 | + * @return bool |
|
| 131 | + */ |
|
| 132 | + public function isBot(); |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * @param bool $is_bot |
|
| 137 | - */ |
|
| 138 | - public function setIsBot($is_bot); |
|
| 135 | + /** |
|
| 136 | + * @param bool $is_bot |
|
| 137 | + */ |
|
| 138 | + public function setIsBot($is_bot); |
|
| 139 | 139 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function setNotice($key, $value) |
| 60 | 60 | { |
| 61 | - $this->notice[ $key ] = $value; |
|
| 61 | + $this->notice[$key] = $value; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function getNotice($key) |
| 71 | 71 | { |
| 72 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
| 72 | + return isset($this->notice[$key]) ? $this->notice[$key] : null; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function addOutput($string, $append = true) |
| 92 | 92 | { |
| 93 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
| 93 | + $this->output = $append ? $this->output.$string : $string.$this->output; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -16,119 +16,119 @@ |
||
| 16 | 16 | class Response implements ResponseInterface, ReservedInstanceInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * @var array $notice |
|
| 21 | - */ |
|
| 22 | - protected $notice = array(); |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * rendered output to be returned to WP |
|
| 26 | - * |
|
| 27 | - * @var string $output |
|
| 28 | - */ |
|
| 29 | - protected $output = ''; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var bool |
|
| 33 | - */ |
|
| 34 | - protected $request_terminated = false; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var bool $deactivate_plugin |
|
| 38 | - */ |
|
| 39 | - protected $deactivate_plugin = false; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * EE_Response constructor. |
|
| 44 | - */ |
|
| 45 | - public function __construct() |
|
| 46 | - { |
|
| 47 | - $this->terminateRequest(false); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @param $key |
|
| 53 | - * @param $value |
|
| 54 | - * @return void |
|
| 55 | - */ |
|
| 56 | - public function setNotice($key, $value) |
|
| 57 | - { |
|
| 58 | - $this->notice[ $key ] = $value; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @param $key |
|
| 64 | - * @return mixed |
|
| 65 | - */ |
|
| 66 | - public function getNotice($key) |
|
| 67 | - { |
|
| 68 | - return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @return array |
|
| 74 | - */ |
|
| 75 | - public function getNotices() |
|
| 76 | - { |
|
| 77 | - return $this->notice; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @param string $string |
|
| 83 | - * @param bool $append |
|
| 84 | - */ |
|
| 85 | - public function addOutput($string, $append = true) |
|
| 86 | - { |
|
| 87 | - $this->output = $append ? $this->output . $string : $string . $this->output; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @return string |
|
| 93 | - */ |
|
| 94 | - public function getOutput() |
|
| 95 | - { |
|
| 96 | - return $this->output; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - |
|
| 100 | - /** |
|
| 101 | - * @return boolean |
|
| 102 | - */ |
|
| 103 | - public function requestTerminated() |
|
| 104 | - { |
|
| 105 | - return $this->request_terminated; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @param boolean $request_terminated |
|
| 111 | - */ |
|
| 112 | - public function terminateRequest($request_terminated = true) |
|
| 113 | - { |
|
| 114 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @return boolean |
|
| 120 | - */ |
|
| 121 | - public function pluginDeactivated() |
|
| 122 | - { |
|
| 123 | - return $this->deactivate_plugin; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * sets $deactivate_plugin to true |
|
| 129 | - */ |
|
| 130 | - public function deactivatePlugin() |
|
| 131 | - { |
|
| 132 | - $this->deactivate_plugin = true; |
|
| 133 | - } |
|
| 19 | + /** |
|
| 20 | + * @var array $notice |
|
| 21 | + */ |
|
| 22 | + protected $notice = array(); |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * rendered output to be returned to WP |
|
| 26 | + * |
|
| 27 | + * @var string $output |
|
| 28 | + */ |
|
| 29 | + protected $output = ''; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var bool |
|
| 33 | + */ |
|
| 34 | + protected $request_terminated = false; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var bool $deactivate_plugin |
|
| 38 | + */ |
|
| 39 | + protected $deactivate_plugin = false; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * EE_Response constructor. |
|
| 44 | + */ |
|
| 45 | + public function __construct() |
|
| 46 | + { |
|
| 47 | + $this->terminateRequest(false); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param $key |
|
| 53 | + * @param $value |
|
| 54 | + * @return void |
|
| 55 | + */ |
|
| 56 | + public function setNotice($key, $value) |
|
| 57 | + { |
|
| 58 | + $this->notice[ $key ] = $value; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @param $key |
|
| 64 | + * @return mixed |
|
| 65 | + */ |
|
| 66 | + public function getNotice($key) |
|
| 67 | + { |
|
| 68 | + return isset($this->notice[ $key ]) ? $this->notice[ $key ] : null; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @return array |
|
| 74 | + */ |
|
| 75 | + public function getNotices() |
|
| 76 | + { |
|
| 77 | + return $this->notice; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @param string $string |
|
| 83 | + * @param bool $append |
|
| 84 | + */ |
|
| 85 | + public function addOutput($string, $append = true) |
|
| 86 | + { |
|
| 87 | + $this->output = $append ? $this->output . $string : $string . $this->output; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @return string |
|
| 93 | + */ |
|
| 94 | + public function getOutput() |
|
| 95 | + { |
|
| 96 | + return $this->output; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + |
|
| 100 | + /** |
|
| 101 | + * @return boolean |
|
| 102 | + */ |
|
| 103 | + public function requestTerminated() |
|
| 104 | + { |
|
| 105 | + return $this->request_terminated; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @param boolean $request_terminated |
|
| 111 | + */ |
|
| 112 | + public function terminateRequest($request_terminated = true) |
|
| 113 | + { |
|
| 114 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @return boolean |
|
| 120 | + */ |
|
| 121 | + public function pluginDeactivated() |
|
| 122 | + { |
|
| 123 | + return $this->deactivate_plugin; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * sets $deactivate_plugin to true |
|
| 129 | + */ |
|
| 130 | + public function deactivatePlugin() |
|
| 131 | + { |
|
| 132 | + $this->deactivate_plugin = true; |
|
| 133 | + } |
|
| 134 | 134 | } |
@@ -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 | class PreProductionVersionWarning extends Middleware |
| 19 | 19 | { |
| 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) |
|
| 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) |
|
| 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'), 10); |
|
| 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'), 10); |
|
| 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 $this->warningNotice(); |
|
| 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 $this->warningNotice(); |
|
| 90 | + echo '</p></div>'; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return string |
|
| 96 | - */ |
|
| 97 | - private function warningNotice() |
|
| 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() |
|
| 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 | } |
@@ -83,7 +83,7 @@ |
||
| 83 | 83 | { |
| 84 | 84 | espresso_load_required( |
| 85 | 85 | 'EE_Request', |
| 86 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 86 | + EE_CORE.'request_stack'.DS.'EE_Request.core.php' |
|
| 87 | 87 | ); |
| 88 | 88 | $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
| 89 | 89 | $this->legacy_request->setRequest($this->request); |
@@ -25,80 +25,80 @@ |
||
| 25 | 25 | class BootstrapRequestResponseObjects |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @type LegacyRequestInterface $legacy_request |
|
| 30 | - */ |
|
| 31 | - protected $legacy_request; |
|
| 28 | + /** |
|
| 29 | + * @type LegacyRequestInterface $legacy_request |
|
| 30 | + */ |
|
| 31 | + protected $legacy_request; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @type LoaderInterface $loader |
|
| 35 | - */ |
|
| 36 | - protected $loader; |
|
| 33 | + /** |
|
| 34 | + * @type LoaderInterface $loader |
|
| 35 | + */ |
|
| 36 | + protected $loader; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @var RequestInterface $request |
|
| 40 | - */ |
|
| 41 | - protected $request; |
|
| 38 | + /** |
|
| 39 | + * @var RequestInterface $request |
|
| 40 | + */ |
|
| 41 | + protected $request; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @var ResponseInterface $response |
|
| 45 | - */ |
|
| 46 | - protected $response; |
|
| 43 | + /** |
|
| 44 | + * @var ResponseInterface $response |
|
| 45 | + */ |
|
| 46 | + protected $response; |
|
| 47 | 47 | |
| 48 | 48 | |
| 49 | - /** |
|
| 50 | - * BootstrapRequestResponseObjects constructor. |
|
| 51 | - * |
|
| 52 | - * @param LoaderInterface $loader |
|
| 53 | - */ |
|
| 54 | - public function __construct(LoaderInterface $loader) |
|
| 55 | - { |
|
| 56 | - $this->loader = $loader; |
|
| 57 | - } |
|
| 49 | + /** |
|
| 50 | + * BootstrapRequestResponseObjects constructor. |
|
| 51 | + * |
|
| 52 | + * @param LoaderInterface $loader |
|
| 53 | + */ |
|
| 54 | + public function __construct(LoaderInterface $loader) |
|
| 55 | + { |
|
| 56 | + $this->loader = $loader; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function buildRequestResponse() |
|
| 64 | - { |
|
| 65 | - // load our Request and Response objects |
|
| 66 | - $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 67 | - $this->response = new Response(); |
|
| 68 | - } |
|
| 60 | + /** |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function buildRequestResponse() |
|
| 64 | + { |
|
| 65 | + // load our Request and Response objects |
|
| 66 | + $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 67 | + $this->response = new Response(); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @return void |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - */ |
|
| 75 | - public function shareRequestResponse() |
|
| 76 | - { |
|
| 77 | - $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
| 78 | - $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
| 79 | - EE_Dependency_Map::instance()->setRequest($this->request); |
|
| 80 | - EE_Dependency_Map::instance()->setResponse($this->response); |
|
| 81 | - } |
|
| 71 | + /** |
|
| 72 | + * @return void |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + */ |
|
| 75 | + public function shareRequestResponse() |
|
| 76 | + { |
|
| 77 | + $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
| 78 | + $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
| 79 | + EE_Dependency_Map::instance()->setRequest($this->request); |
|
| 80 | + EE_Dependency_Map::instance()->setResponse($this->response); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | 83 | |
| 84 | - /** |
|
| 85 | - * @return void |
|
| 86 | - * @throws InvalidArgumentException |
|
| 87 | - * @throws EE_Error |
|
| 88 | - */ |
|
| 89 | - public function setupLegacyRequest() |
|
| 90 | - { |
|
| 91 | - espresso_load_required( |
|
| 92 | - 'EE_Request', |
|
| 93 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 94 | - ); |
|
| 95 | - $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 96 | - $this->legacy_request->setRequest($this->request); |
|
| 97 | - $this->legacy_request->admin = $this->request->isAdmin(); |
|
| 98 | - $this->legacy_request->ajax = $this->request->isAjax(); |
|
| 99 | - $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
| 100 | - EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
| 101 | - $this->loader->share('EE_Request', $this->legacy_request); |
|
| 102 | - $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
| 103 | - } |
|
| 84 | + /** |
|
| 85 | + * @return void |
|
| 86 | + * @throws InvalidArgumentException |
|
| 87 | + * @throws EE_Error |
|
| 88 | + */ |
|
| 89 | + public function setupLegacyRequest() |
|
| 90 | + { |
|
| 91 | + espresso_load_required( |
|
| 92 | + 'EE_Request', |
|
| 93 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 94 | + ); |
|
| 95 | + $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 96 | + $this->legacy_request->setRequest($this->request); |
|
| 97 | + $this->legacy_request->admin = $this->request->isAdmin(); |
|
| 98 | + $this->legacy_request->ajax = $this->request->isAjax(); |
|
| 99 | + $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
| 100 | + EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
| 101 | + $this->loader->share('EE_Request', $this->legacy_request); |
|
| 102 | + $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * |
| 182 | 182 | * @deprecated 4.9.53 |
| 183 | 183 | * @param $key |
| 184 | - * @param null $default |
|
| 184 | + * @param null|string $default |
|
| 185 | 185 | * @return mixed |
| 186 | 186 | * @throws InvalidArgumentException |
| 187 | 187 | * @throws InvalidDataTypeException |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * @deprecated 4.9.53 |
| 259 | - * @return mixed |
|
| 259 | + * @return boolean |
|
| 260 | 260 | * @throws InvalidArgumentException |
| 261 | 261 | * @throws InvalidDataTypeException |
| 262 | 262 | * @throws InvalidInterfaceException |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | |
| 270 | 270 | /** |
| 271 | 271 | * @deprecated 4.9.53 |
| 272 | - * @return mixed |
|
| 272 | + * @return boolean |
|
| 273 | 273 | * @throws InvalidArgumentException |
| 274 | 274 | * @throws InvalidDataTypeException |
| 275 | 275 | * @throws InvalidInterfaceException |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | /** |
| 284 | 284 | * @deprecated 4.9.53 |
| 285 | - * @return mixed|string |
|
| 285 | + * @return string |
|
| 286 | 286 | * @throws InvalidArgumentException |
| 287 | 287 | * @throws InvalidDataTypeException |
| 288 | 288 | * @throws InvalidInterfaceException |
@@ -18,359 +18,359 @@ |
||
| 18 | 18 | class EE_Request implements LegacyRequestInterface, InterminableInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var RequestInterface $request |
|
| 23 | - */ |
|
| 24 | - private $request; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * whether current request is for the admin but NOT via AJAX |
|
| 28 | - * |
|
| 29 | - * @var boolean $admin |
|
| 30 | - */ |
|
| 31 | - public $admin = false; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * whether current request is via AJAX |
|
| 35 | - * |
|
| 36 | - * @var boolean $ajax |
|
| 37 | - */ |
|
| 38 | - public $ajax = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * whether current request is via AJAX from the frontend of the site |
|
| 42 | - * |
|
| 43 | - * @var boolean $front_ajax |
|
| 44 | - */ |
|
| 45 | - public $front_ajax = false; |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @deprecated 4.9.53 |
|
| 50 | - * @param array $get |
|
| 51 | - * @param array $post |
|
| 52 | - * @param array $cookie |
|
| 53 | - * @param array $server |
|
| 54 | - */ |
|
| 55 | - public function __construct( |
|
| 56 | - array $get = array(), |
|
| 57 | - array $post = array(), |
|
| 58 | - array $cookie = array(), |
|
| 59 | - array $server = array() |
|
| 60 | - ) { |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @return RequestInterface |
|
| 66 | - * @throws InvalidArgumentException |
|
| 67 | - * @throws InvalidInterfaceException |
|
| 68 | - * @throws InvalidDataTypeException |
|
| 69 | - */ |
|
| 70 | - private function request() |
|
| 71 | - { |
|
| 72 | - if ($this->request instanceof RequestInterface) { |
|
| 73 | - return $this->request; |
|
| 74 | - } |
|
| 75 | - $loader = LoaderFactory::getLoader(); |
|
| 76 | - $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
| 77 | - return $this->request; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @param RequestInterface $request |
|
| 83 | - */ |
|
| 84 | - public function setRequest(RequestInterface $request) |
|
| 85 | - { |
|
| 86 | - $this->request = $request; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * @deprecated 4.9.53 |
|
| 92 | - * @return array |
|
| 93 | - * @throws InvalidArgumentException |
|
| 94 | - * @throws InvalidDataTypeException |
|
| 95 | - * @throws InvalidInterfaceException |
|
| 96 | - */ |
|
| 97 | - public function get_params() |
|
| 98 | - { |
|
| 99 | - return $this->request()->getParams(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @deprecated 4.9.53 |
|
| 105 | - * @return array |
|
| 106 | - * @throws InvalidArgumentException |
|
| 107 | - * @throws InvalidDataTypeException |
|
| 108 | - * @throws InvalidInterfaceException |
|
| 109 | - */ |
|
| 110 | - public function post_params() |
|
| 111 | - { |
|
| 112 | - return $this->request()->postParams(); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @deprecated 4.9.53 |
|
| 118 | - * @return array |
|
| 119 | - * @throws InvalidArgumentException |
|
| 120 | - * @throws InvalidDataTypeException |
|
| 121 | - * @throws InvalidInterfaceException |
|
| 122 | - */ |
|
| 123 | - public function cookie_params() |
|
| 124 | - { |
|
| 125 | - return $this->request()->cookieParams(); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @deprecated 4.9.53 |
|
| 131 | - * @return array |
|
| 132 | - * @throws InvalidArgumentException |
|
| 133 | - * @throws InvalidDataTypeException |
|
| 134 | - * @throws InvalidInterfaceException |
|
| 135 | - */ |
|
| 136 | - public function server_params() |
|
| 137 | - { |
|
| 138 | - return $this->request()->serverParams(); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * returns contents of $_REQUEST |
|
| 144 | - * |
|
| 145 | - * @deprecated 4.9.53 |
|
| 146 | - * @return array |
|
| 147 | - * @throws InvalidArgumentException |
|
| 148 | - * @throws InvalidDataTypeException |
|
| 149 | - * @throws InvalidInterfaceException |
|
| 150 | - */ |
|
| 151 | - public function params() |
|
| 152 | - { |
|
| 153 | - return $this->request()->requestParams(); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @deprecated 4.9.53 |
|
| 159 | - * @param $key |
|
| 160 | - * @param $value |
|
| 161 | - * @param bool $override_ee |
|
| 162 | - * @return void |
|
| 163 | - * @throws InvalidArgumentException |
|
| 164 | - * @throws InvalidDataTypeException |
|
| 165 | - * @throws InvalidInterfaceException |
|
| 166 | - */ |
|
| 167 | - public function set($key, $value, $override_ee = false) |
|
| 168 | - { |
|
| 169 | - $this->request()->setRequestParam($key, $value, $override_ee); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * returns the value for a request param if the given key exists |
|
| 175 | - * |
|
| 176 | - * @deprecated 4.9.53 |
|
| 177 | - * @param $key |
|
| 178 | - * @param null $default |
|
| 179 | - * @return mixed |
|
| 180 | - * @throws InvalidArgumentException |
|
| 181 | - * @throws InvalidDataTypeException |
|
| 182 | - * @throws InvalidInterfaceException |
|
| 183 | - */ |
|
| 184 | - public function get($key, $default = null) |
|
| 185 | - { |
|
| 186 | - return $this->request()->getRequestParam($key, $default); |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * check if param exists |
|
| 192 | - * |
|
| 193 | - * @deprecated 4.9.53 |
|
| 194 | - * @param $key |
|
| 195 | - * @return bool |
|
| 196 | - * @throws InvalidArgumentException |
|
| 197 | - * @throws InvalidDataTypeException |
|
| 198 | - * @throws InvalidInterfaceException |
|
| 199 | - */ |
|
| 200 | - public function is_set($key) |
|
| 201 | - { |
|
| 202 | - return $this->request()->requestParamIsSet($key); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * remove param |
|
| 208 | - * |
|
| 209 | - * @deprecated 4.9.53 |
|
| 210 | - * @param $key |
|
| 211 | - * @param bool $unset_from_global_too |
|
| 212 | - * @throws InvalidArgumentException |
|
| 213 | - * @throws InvalidDataTypeException |
|
| 214 | - * @throws InvalidInterfaceException |
|
| 215 | - */ |
|
| 216 | - public function un_set($key, $unset_from_global_too = false) |
|
| 217 | - { |
|
| 218 | - $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * @deprecated 4.9.53 |
|
| 224 | - * @return string |
|
| 225 | - * @throws InvalidArgumentException |
|
| 226 | - * @throws InvalidDataTypeException |
|
| 227 | - * @throws InvalidInterfaceException |
|
| 228 | - */ |
|
| 229 | - public function ip_address() |
|
| 230 | - { |
|
| 231 | - return $this->request()->ipAddress(); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @deprecated 4.9.53 |
|
| 237 | - * @return bool |
|
| 238 | - * @throws InvalidArgumentException |
|
| 239 | - * @throws InvalidDataTypeException |
|
| 240 | - * @throws InvalidInterfaceException |
|
| 241 | - */ |
|
| 242 | - public function isAdmin() |
|
| 243 | - { |
|
| 244 | - return $this->request()->isAdmin(); |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @deprecated 4.9.53 |
|
| 250 | - * @return mixed |
|
| 251 | - * @throws InvalidArgumentException |
|
| 252 | - * @throws InvalidDataTypeException |
|
| 253 | - * @throws InvalidInterfaceException |
|
| 254 | - */ |
|
| 255 | - public function isAjax() |
|
| 256 | - { |
|
| 257 | - return $this->request()->isAjax(); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - |
|
| 261 | - /** |
|
| 262 | - * @deprecated 4.9.53 |
|
| 263 | - * @return mixed |
|
| 264 | - * @throws InvalidArgumentException |
|
| 265 | - * @throws InvalidDataTypeException |
|
| 266 | - * @throws InvalidInterfaceException |
|
| 267 | - */ |
|
| 268 | - public function isFrontAjax() |
|
| 269 | - { |
|
| 270 | - return $this->request()->isFrontAjax(); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * @deprecated 4.9.53 |
|
| 276 | - * @return mixed|string |
|
| 277 | - * @throws InvalidArgumentException |
|
| 278 | - * @throws InvalidDataTypeException |
|
| 279 | - * @throws InvalidInterfaceException |
|
| 280 | - */ |
|
| 281 | - public function requestUri() |
|
| 282 | - { |
|
| 283 | - return $this->request()->requestUri(); |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - |
|
| 287 | - /** |
|
| 288 | - * @deprecated 4.9.53 |
|
| 289 | - * @return string |
|
| 290 | - * @throws InvalidArgumentException |
|
| 291 | - * @throws InvalidDataTypeException |
|
| 292 | - * @throws InvalidInterfaceException |
|
| 293 | - */ |
|
| 294 | - public function userAgent() |
|
| 295 | - { |
|
| 296 | - return $this->request()->userAgent(); |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - |
|
| 300 | - /** |
|
| 301 | - * @deprecated 4.9.53 |
|
| 302 | - * @param string $user_agent |
|
| 303 | - * @throws InvalidArgumentException |
|
| 304 | - * @throws InvalidDataTypeException |
|
| 305 | - * @throws InvalidInterfaceException |
|
| 306 | - */ |
|
| 307 | - public function setUserAgent($user_agent = '') |
|
| 308 | - { |
|
| 309 | - $this->request()->setUserAgent($user_agent); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * @deprecated 4.9.53 |
|
| 315 | - * @return bool |
|
| 316 | - * @throws InvalidArgumentException |
|
| 317 | - * @throws InvalidDataTypeException |
|
| 318 | - * @throws InvalidInterfaceException |
|
| 319 | - */ |
|
| 320 | - public function isBot() |
|
| 321 | - { |
|
| 322 | - return $this->request()->isBot(); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - |
|
| 326 | - /** |
|
| 327 | - * @deprecated 4.9.53 |
|
| 328 | - * @param bool $is_bot |
|
| 329 | - * @throws InvalidArgumentException |
|
| 330 | - * @throws InvalidDataTypeException |
|
| 331 | - * @throws InvalidInterfaceException |
|
| 332 | - */ |
|
| 333 | - public function setIsBot($is_bot) |
|
| 334 | - { |
|
| 335 | - $this->request()->setIsBot($is_bot); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
| 341 | - * and return the value for the first match found |
|
| 342 | - * wildcards can be either of the following: |
|
| 343 | - * ? to represent a single character of any type |
|
| 344 | - * * to represent one or more characters of any type |
|
| 345 | - * |
|
| 346 | - * @param string $pattern |
|
| 347 | - * @param null|mixed $default |
|
| 348 | - * @return false|int |
|
| 349 | - * @throws InvalidArgumentException |
|
| 350 | - * @throws InvalidInterfaceException |
|
| 351 | - * @throws InvalidDataTypeException |
|
| 352 | - */ |
|
| 353 | - public function getMatch($pattern, $default = null) |
|
| 354 | - { |
|
| 355 | - return $this->request()->getMatch($pattern, $default); |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - |
|
| 359 | - /** |
|
| 360 | - * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
| 361 | - * wildcards can be either of the following: |
|
| 362 | - * ? to represent a single character of any type |
|
| 363 | - * * to represent one or more characters of any type |
|
| 364 | - * returns true if a match is found or false if not |
|
| 365 | - * |
|
| 366 | - * @param string $pattern |
|
| 367 | - * @return false|int |
|
| 368 | - * @throws InvalidArgumentException |
|
| 369 | - * @throws InvalidInterfaceException |
|
| 370 | - * @throws InvalidDataTypeException |
|
| 371 | - */ |
|
| 372 | - public function matches($pattern) |
|
| 373 | - { |
|
| 374 | - return $this->request()->matches($pattern); |
|
| 375 | - } |
|
| 21 | + /** |
|
| 22 | + * @var RequestInterface $request |
|
| 23 | + */ |
|
| 24 | + private $request; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * whether current request is for the admin but NOT via AJAX |
|
| 28 | + * |
|
| 29 | + * @var boolean $admin |
|
| 30 | + */ |
|
| 31 | + public $admin = false; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * whether current request is via AJAX |
|
| 35 | + * |
|
| 36 | + * @var boolean $ajax |
|
| 37 | + */ |
|
| 38 | + public $ajax = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * whether current request is via AJAX from the frontend of the site |
|
| 42 | + * |
|
| 43 | + * @var boolean $front_ajax |
|
| 44 | + */ |
|
| 45 | + public $front_ajax = false; |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @deprecated 4.9.53 |
|
| 50 | + * @param array $get |
|
| 51 | + * @param array $post |
|
| 52 | + * @param array $cookie |
|
| 53 | + * @param array $server |
|
| 54 | + */ |
|
| 55 | + public function __construct( |
|
| 56 | + array $get = array(), |
|
| 57 | + array $post = array(), |
|
| 58 | + array $cookie = array(), |
|
| 59 | + array $server = array() |
|
| 60 | + ) { |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @return RequestInterface |
|
| 66 | + * @throws InvalidArgumentException |
|
| 67 | + * @throws InvalidInterfaceException |
|
| 68 | + * @throws InvalidDataTypeException |
|
| 69 | + */ |
|
| 70 | + private function request() |
|
| 71 | + { |
|
| 72 | + if ($this->request instanceof RequestInterface) { |
|
| 73 | + return $this->request; |
|
| 74 | + } |
|
| 75 | + $loader = LoaderFactory::getLoader(); |
|
| 76 | + $this->request = $loader->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
| 77 | + return $this->request; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @param RequestInterface $request |
|
| 83 | + */ |
|
| 84 | + public function setRequest(RequestInterface $request) |
|
| 85 | + { |
|
| 86 | + $this->request = $request; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * @deprecated 4.9.53 |
|
| 92 | + * @return array |
|
| 93 | + * @throws InvalidArgumentException |
|
| 94 | + * @throws InvalidDataTypeException |
|
| 95 | + * @throws InvalidInterfaceException |
|
| 96 | + */ |
|
| 97 | + public function get_params() |
|
| 98 | + { |
|
| 99 | + return $this->request()->getParams(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @deprecated 4.9.53 |
|
| 105 | + * @return array |
|
| 106 | + * @throws InvalidArgumentException |
|
| 107 | + * @throws InvalidDataTypeException |
|
| 108 | + * @throws InvalidInterfaceException |
|
| 109 | + */ |
|
| 110 | + public function post_params() |
|
| 111 | + { |
|
| 112 | + return $this->request()->postParams(); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @deprecated 4.9.53 |
|
| 118 | + * @return array |
|
| 119 | + * @throws InvalidArgumentException |
|
| 120 | + * @throws InvalidDataTypeException |
|
| 121 | + * @throws InvalidInterfaceException |
|
| 122 | + */ |
|
| 123 | + public function cookie_params() |
|
| 124 | + { |
|
| 125 | + return $this->request()->cookieParams(); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @deprecated 4.9.53 |
|
| 131 | + * @return array |
|
| 132 | + * @throws InvalidArgumentException |
|
| 133 | + * @throws InvalidDataTypeException |
|
| 134 | + * @throws InvalidInterfaceException |
|
| 135 | + */ |
|
| 136 | + public function server_params() |
|
| 137 | + { |
|
| 138 | + return $this->request()->serverParams(); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * returns contents of $_REQUEST |
|
| 144 | + * |
|
| 145 | + * @deprecated 4.9.53 |
|
| 146 | + * @return array |
|
| 147 | + * @throws InvalidArgumentException |
|
| 148 | + * @throws InvalidDataTypeException |
|
| 149 | + * @throws InvalidInterfaceException |
|
| 150 | + */ |
|
| 151 | + public function params() |
|
| 152 | + { |
|
| 153 | + return $this->request()->requestParams(); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @deprecated 4.9.53 |
|
| 159 | + * @param $key |
|
| 160 | + * @param $value |
|
| 161 | + * @param bool $override_ee |
|
| 162 | + * @return void |
|
| 163 | + * @throws InvalidArgumentException |
|
| 164 | + * @throws InvalidDataTypeException |
|
| 165 | + * @throws InvalidInterfaceException |
|
| 166 | + */ |
|
| 167 | + public function set($key, $value, $override_ee = false) |
|
| 168 | + { |
|
| 169 | + $this->request()->setRequestParam($key, $value, $override_ee); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * returns the value for a request param if the given key exists |
|
| 175 | + * |
|
| 176 | + * @deprecated 4.9.53 |
|
| 177 | + * @param $key |
|
| 178 | + * @param null $default |
|
| 179 | + * @return mixed |
|
| 180 | + * @throws InvalidArgumentException |
|
| 181 | + * @throws InvalidDataTypeException |
|
| 182 | + * @throws InvalidInterfaceException |
|
| 183 | + */ |
|
| 184 | + public function get($key, $default = null) |
|
| 185 | + { |
|
| 186 | + return $this->request()->getRequestParam($key, $default); |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * check if param exists |
|
| 192 | + * |
|
| 193 | + * @deprecated 4.9.53 |
|
| 194 | + * @param $key |
|
| 195 | + * @return bool |
|
| 196 | + * @throws InvalidArgumentException |
|
| 197 | + * @throws InvalidDataTypeException |
|
| 198 | + * @throws InvalidInterfaceException |
|
| 199 | + */ |
|
| 200 | + public function is_set($key) |
|
| 201 | + { |
|
| 202 | + return $this->request()->requestParamIsSet($key); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * remove param |
|
| 208 | + * |
|
| 209 | + * @deprecated 4.9.53 |
|
| 210 | + * @param $key |
|
| 211 | + * @param bool $unset_from_global_too |
|
| 212 | + * @throws InvalidArgumentException |
|
| 213 | + * @throws InvalidDataTypeException |
|
| 214 | + * @throws InvalidInterfaceException |
|
| 215 | + */ |
|
| 216 | + public function un_set($key, $unset_from_global_too = false) |
|
| 217 | + { |
|
| 218 | + $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * @deprecated 4.9.53 |
|
| 224 | + * @return string |
|
| 225 | + * @throws InvalidArgumentException |
|
| 226 | + * @throws InvalidDataTypeException |
|
| 227 | + * @throws InvalidInterfaceException |
|
| 228 | + */ |
|
| 229 | + public function ip_address() |
|
| 230 | + { |
|
| 231 | + return $this->request()->ipAddress(); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @deprecated 4.9.53 |
|
| 237 | + * @return bool |
|
| 238 | + * @throws InvalidArgumentException |
|
| 239 | + * @throws InvalidDataTypeException |
|
| 240 | + * @throws InvalidInterfaceException |
|
| 241 | + */ |
|
| 242 | + public function isAdmin() |
|
| 243 | + { |
|
| 244 | + return $this->request()->isAdmin(); |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @deprecated 4.9.53 |
|
| 250 | + * @return mixed |
|
| 251 | + * @throws InvalidArgumentException |
|
| 252 | + * @throws InvalidDataTypeException |
|
| 253 | + * @throws InvalidInterfaceException |
|
| 254 | + */ |
|
| 255 | + public function isAjax() |
|
| 256 | + { |
|
| 257 | + return $this->request()->isAjax(); |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + |
|
| 261 | + /** |
|
| 262 | + * @deprecated 4.9.53 |
|
| 263 | + * @return mixed |
|
| 264 | + * @throws InvalidArgumentException |
|
| 265 | + * @throws InvalidDataTypeException |
|
| 266 | + * @throws InvalidInterfaceException |
|
| 267 | + */ |
|
| 268 | + public function isFrontAjax() |
|
| 269 | + { |
|
| 270 | + return $this->request()->isFrontAjax(); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * @deprecated 4.9.53 |
|
| 276 | + * @return mixed|string |
|
| 277 | + * @throws InvalidArgumentException |
|
| 278 | + * @throws InvalidDataTypeException |
|
| 279 | + * @throws InvalidInterfaceException |
|
| 280 | + */ |
|
| 281 | + public function requestUri() |
|
| 282 | + { |
|
| 283 | + return $this->request()->requestUri(); |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + |
|
| 287 | + /** |
|
| 288 | + * @deprecated 4.9.53 |
|
| 289 | + * @return string |
|
| 290 | + * @throws InvalidArgumentException |
|
| 291 | + * @throws InvalidDataTypeException |
|
| 292 | + * @throws InvalidInterfaceException |
|
| 293 | + */ |
|
| 294 | + public function userAgent() |
|
| 295 | + { |
|
| 296 | + return $this->request()->userAgent(); |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + |
|
| 300 | + /** |
|
| 301 | + * @deprecated 4.9.53 |
|
| 302 | + * @param string $user_agent |
|
| 303 | + * @throws InvalidArgumentException |
|
| 304 | + * @throws InvalidDataTypeException |
|
| 305 | + * @throws InvalidInterfaceException |
|
| 306 | + */ |
|
| 307 | + public function setUserAgent($user_agent = '') |
|
| 308 | + { |
|
| 309 | + $this->request()->setUserAgent($user_agent); |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * @deprecated 4.9.53 |
|
| 315 | + * @return bool |
|
| 316 | + * @throws InvalidArgumentException |
|
| 317 | + * @throws InvalidDataTypeException |
|
| 318 | + * @throws InvalidInterfaceException |
|
| 319 | + */ |
|
| 320 | + public function isBot() |
|
| 321 | + { |
|
| 322 | + return $this->request()->isBot(); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * @deprecated 4.9.53 |
|
| 328 | + * @param bool $is_bot |
|
| 329 | + * @throws InvalidArgumentException |
|
| 330 | + * @throws InvalidDataTypeException |
|
| 331 | + * @throws InvalidInterfaceException |
|
| 332 | + */ |
|
| 333 | + public function setIsBot($is_bot) |
|
| 334 | + { |
|
| 335 | + $this->request()->setIsBot($is_bot); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * check if a request parameter exists whose key that matches the supplied wildcard pattern |
|
| 341 | + * and return the value for the first match found |
|
| 342 | + * wildcards can be either of the following: |
|
| 343 | + * ? to represent a single character of any type |
|
| 344 | + * * to represent one or more characters of any type |
|
| 345 | + * |
|
| 346 | + * @param string $pattern |
|
| 347 | + * @param null|mixed $default |
|
| 348 | + * @return false|int |
|
| 349 | + * @throws InvalidArgumentException |
|
| 350 | + * @throws InvalidInterfaceException |
|
| 351 | + * @throws InvalidDataTypeException |
|
| 352 | + */ |
|
| 353 | + public function getMatch($pattern, $default = null) |
|
| 354 | + { |
|
| 355 | + return $this->request()->getMatch($pattern, $default); |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + |
|
| 359 | + /** |
|
| 360 | + * check if a request parameter exists whose key matches the supplied wildcard pattern |
|
| 361 | + * wildcards can be either of the following: |
|
| 362 | + * ? to represent a single character of any type |
|
| 363 | + * * to represent one or more characters of any type |
|
| 364 | + * returns true if a match is found or false if not |
|
| 365 | + * |
|
| 366 | + * @param string $pattern |
|
| 367 | + * @return false|int |
|
| 368 | + * @throws InvalidArgumentException |
|
| 369 | + * @throws InvalidInterfaceException |
|
| 370 | + * @throws InvalidDataTypeException |
|
| 371 | + */ |
|
| 372 | + public function matches($pattern) |
|
| 373 | + { |
|
| 374 | + return $this->request()->matches($pattern); |
|
| 375 | + } |
|
| 376 | 376 | } |
@@ -19,59 +19,59 @@ |
||
| 19 | 19 | class RequestStack |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var RequestDecoratorInterface $request_stack_app |
|
| 24 | - */ |
|
| 25 | - protected $request_stack_app; |
|
| 22 | + /** |
|
| 23 | + * @var RequestDecoratorInterface $request_stack_app |
|
| 24 | + */ |
|
| 25 | + protected $request_stack_app; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @var RequestStackCoreAppInterface $core_app |
|
| 29 | - */ |
|
| 30 | - protected $core_app; |
|
| 27 | + /** |
|
| 28 | + * @var RequestStackCoreAppInterface $core_app |
|
| 29 | + */ |
|
| 30 | + protected $core_app; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var RequestInterface $request |
|
| 34 | - */ |
|
| 35 | - protected $request; |
|
| 32 | + /** |
|
| 33 | + * @var RequestInterface $request |
|
| 34 | + */ |
|
| 35 | + protected $request; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var ResponseInterface $response |
|
| 39 | - */ |
|
| 40 | - protected $response; |
|
| 37 | + /** |
|
| 38 | + * @var ResponseInterface $response |
|
| 39 | + */ |
|
| 40 | + protected $response; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param RequestDecoratorInterface $request_stack_app |
|
| 45 | - * @param RequestStackCoreAppInterface $core_app |
|
| 46 | - */ |
|
| 47 | - public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
|
| 48 | - { |
|
| 49 | - $this->request_stack_app = $request_stack_app; |
|
| 50 | - $this->core_app = $core_app; |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * @param RequestDecoratorInterface $request_stack_app |
|
| 45 | + * @param RequestStackCoreAppInterface $core_app |
|
| 46 | + */ |
|
| 47 | + public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
|
| 48 | + { |
|
| 49 | + $this->request_stack_app = $request_stack_app; |
|
| 50 | + $this->core_app = $core_app; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param RequestInterface $request |
|
| 56 | - * @param ResponseInterface $response |
|
| 57 | - * @return ResponseInterface |
|
| 58 | - */ |
|
| 59 | - public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 60 | - { |
|
| 61 | - $this->request = $request; |
|
| 62 | - $this->response = $response; |
|
| 63 | - return $this->request_stack_app->handleRequest($request, $response); |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * @param RequestInterface $request |
|
| 56 | + * @param ResponseInterface $response |
|
| 57 | + * @return ResponseInterface |
|
| 58 | + */ |
|
| 59 | + public function handleRequest(RequestInterface $request, ResponseInterface $response) |
|
| 60 | + { |
|
| 61 | + $this->request = $request; |
|
| 62 | + $this->response = $response; |
|
| 63 | + return $this->request_stack_app->handleRequest($request, $response); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | 66 | |
| 67 | - /** |
|
| 68 | - * handle_response |
|
| 69 | - * executes the handle_response() method on the RequestStackCoreAppInterface object |
|
| 70 | - * after the request stack has been fully processed |
|
| 71 | - */ |
|
| 72 | - public function handleResponse() |
|
| 73 | - { |
|
| 74 | - $this->core_app->handleResponse($this->request, $this->response); |
|
| 75 | - } |
|
| 67 | + /** |
|
| 68 | + * handle_response |
|
| 69 | + * executes the handle_response() method on the RequestStackCoreAppInterface object |
|
| 70 | + * after the request stack has been fully processed |
|
| 71 | + */ |
|
| 72 | + public function handleResponse() |
|
| 73 | + { |
|
| 74 | + $this->core_app->handleResponse($this->request, $this->response); |
|
| 75 | + } |
|
| 76 | 76 | } |
| 77 | 77 | // Location: RequestStack.php |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | public function __construct(RequestDecoratorInterface $request_stack_app, RequestStackCoreAppInterface $core_app) |
| 48 | 48 | { |
| 49 | 49 | $this->request_stack_app = $request_stack_app; |
| 50 | - $this->core_app = $core_app; |
|
| 50 | + $this->core_app = $core_app; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | |