@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * OpenCoffeeShop constructor |
|
| 35 | - * |
|
| 36 | - * @throws InvalidInterfaceException |
|
| 37 | - */ |
|
| 33 | + /** |
|
| 34 | + * OpenCoffeeShop constructor |
|
| 35 | + * |
|
| 36 | + * @throws InvalidInterfaceException |
|
| 37 | + */ |
|
| 38 | 38 | public function __construct() |
| 39 | - { |
|
| 40 | - // instantiate the DI container |
|
| 39 | + { |
|
| 40 | + // instantiate the DI container |
|
| 41 | 41 | $this->CoffeeShop = new CoffeeShop(); |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
@@ -52,60 +52,60 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * configure coffee makers which control the different kinds of brews |
|
| 57 | - * ( shared services, new factory objects, etc ) |
|
| 58 | - * |
|
| 59 | - * @throws InvalidEntityException |
|
| 60 | - */ |
|
| 55 | + /** |
|
| 56 | + * configure coffee makers which control the different kinds of brews |
|
| 57 | + * ( shared services, new factory objects, etc ) |
|
| 58 | + * |
|
| 59 | + * @throws InvalidEntityException |
|
| 60 | + */ |
|
| 61 | 61 | public function setupCoffeeMakers() { |
| 62 | - // create a dependency injector class for resolving class constructor arguments |
|
| 63 | - $DependencyInjector = new DependencyInjector( |
|
| 64 | - $this->CoffeeShop, |
|
| 65 | - new \EEH_Array() |
|
| 66 | - ); |
|
| 67 | - // and some coffeemakers, one for creating new instances |
|
| 68 | - $this->CoffeeShop->addCoffeeMaker( |
|
| 69 | - new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 70 | - CoffeeMaker::BREW_NEW |
|
| 71 | - ); |
|
| 72 | - // one for shared services |
|
| 73 | - $this->CoffeeShop->addCoffeeMaker( |
|
| 74 | - new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 75 | - CoffeeMaker::BREW_SHARED |
|
| 76 | - ); |
|
| 77 | - // and one for classes that only get loaded |
|
| 78 | - $this->CoffeeShop->addCoffeeMaker( |
|
| 79 | - new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 80 | - CoffeeMaker::BREW_LOAD_ONLY |
|
| 81 | - ); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * Recipes define how to load legacy classes |
|
| 88 | - * |
|
| 89 | - * @throws InvalidIdentifierException |
|
| 90 | - */ |
|
| 91 | - public function addRecipes() { |
|
| 92 | - // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
| 93 | - // as long as they are not type hinting for interfaces |
|
| 94 | - $this->CoffeeShop->addRecipe( |
|
| 95 | - new Recipe( |
|
| 96 | - Recipe::DEFAULT_ID |
|
| 97 | - ) |
|
| 98 | - ); |
|
| 99 | - // PSR-4 compatible class with aliases |
|
| 62 | + // create a dependency injector class for resolving class constructor arguments |
|
| 63 | + $DependencyInjector = new DependencyInjector( |
|
| 64 | + $this->CoffeeShop, |
|
| 65 | + new \EEH_Array() |
|
| 66 | + ); |
|
| 67 | + // and some coffeemakers, one for creating new instances |
|
| 68 | + $this->CoffeeShop->addCoffeeMaker( |
|
| 69 | + new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 70 | + CoffeeMaker::BREW_NEW |
|
| 71 | + ); |
|
| 72 | + // one for shared services |
|
| 73 | + $this->CoffeeShop->addCoffeeMaker( |
|
| 74 | + new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 75 | + CoffeeMaker::BREW_SHARED |
|
| 76 | + ); |
|
| 77 | + // and one for classes that only get loaded |
|
| 78 | + $this->CoffeeShop->addCoffeeMaker( |
|
| 79 | + new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
| 80 | + CoffeeMaker::BREW_LOAD_ONLY |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * Recipes define how to load legacy classes |
|
| 88 | + * |
|
| 89 | + * @throws InvalidIdentifierException |
|
| 90 | + */ |
|
| 91 | + public function addRecipes() { |
|
| 92 | + // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
| 93 | + // as long as they are not type hinting for interfaces |
|
| 94 | + $this->CoffeeShop->addRecipe( |
|
| 95 | + new Recipe( |
|
| 96 | + Recipe::DEFAULT_ID |
|
| 97 | + ) |
|
| 98 | + ); |
|
| 99 | + // PSR-4 compatible class with aliases |
|
| 100 | 100 | $this->CoffeeShop->addRecipe( |
| 101 | 101 | new Recipe( |
| 102 | 102 | 'CommandHandlerManager', |
| 103 | 103 | 'EventEspresso\core\services\commands\CommandHandlerManager', |
| 104 | - array( |
|
| 105 | - 'CommandHandlerManagerInterface', |
|
| 106 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 107 | - ), |
|
| 108 | - array(), |
|
| 104 | + array( |
|
| 105 | + 'CommandHandlerManagerInterface', |
|
| 106 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 107 | + ), |
|
| 108 | + array(), |
|
| 109 | 109 | CoffeeMaker::BREW_SHARED |
| 110 | 110 | ) |
| 111 | 111 | ); |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | new Recipe( |
| 115 | 115 | 'CommandBus', |
| 116 | 116 | 'EventEspresso\core\services\commands\CommandBus', |
| 117 | - array( |
|
| 118 | - 'CommandBusInterface', |
|
| 119 | - 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 120 | - ), |
|
| 121 | - array(), |
|
| 117 | + array( |
|
| 118 | + 'CommandBusInterface', |
|
| 119 | + 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 120 | + ), |
|
| 121 | + array(), |
|
| 122 | 122 | CoffeeMaker::BREW_SHARED |
| 123 | 123 | ) |
| 124 | 124 | ); |
@@ -128,22 +128,22 @@ discard block |
||
| 128 | 128 | new Recipe( |
| 129 | 129 | 'EEI_*', |
| 130 | 130 | '', |
| 131 | - array(), |
|
| 132 | - array(), |
|
| 131 | + array(), |
|
| 132 | + array(), |
|
| 133 | 133 | CoffeeMaker::BREW_LOAD_ONLY, |
| 134 | - array( |
|
| 135 | - EE_INTERFACES . '*.php', |
|
| 136 | - EE_INTERFACES . '*.interfaces.php', |
|
| 137 | - ) |
|
| 134 | + array( |
|
| 135 | + EE_INTERFACES . '*.php', |
|
| 136 | + EE_INTERFACES . '*.interfaces.php', |
|
| 137 | + ) |
|
| 138 | 138 | ) |
| 139 | 139 | ); |
| 140 | 140 | // add a wildcard recipe for loading models |
| 141 | 141 | $this->CoffeeShop->addRecipe( |
| 142 | 142 | new Recipe( |
| 143 | 143 | 'EEM_*', |
| 144 | - '', |
|
| 145 | - array(), |
|
| 146 | - array(), |
|
| 144 | + '', |
|
| 145 | + array(), |
|
| 146 | + array(), |
|
| 147 | 147 | CoffeeMaker::BREW_SHARED, |
| 148 | 148 | EE_MODELS . '*.model.php' |
| 149 | 149 | ) |
@@ -152,10 +152,10 @@ discard block |
||
| 152 | 152 | $this->CoffeeShop->addRecipe( |
| 153 | 153 | new Recipe( |
| 154 | 154 | 'EE_*', |
| 155 | - '', |
|
| 156 | - array(), |
|
| 157 | - array(), |
|
| 158 | - CoffeeMaker::BREW_SHARED, |
|
| 155 | + '', |
|
| 156 | + array(), |
|
| 157 | + array(), |
|
| 158 | + CoffeeMaker::BREW_SHARED, |
|
| 159 | 159 | array( |
| 160 | 160 | EE_CORE . '*.core.php', |
| 161 | 161 | EE_ADMIN . '*.core.php', |
@@ -168,10 +168,10 @@ discard block |
||
| 168 | 168 | $this->CoffeeShop->addRecipe( |
| 169 | 169 | new Recipe( |
| 170 | 170 | 'EE_Admin_Page*', |
| 171 | - '', |
|
| 172 | - array(), |
|
| 173 | - array(), |
|
| 174 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
| 171 | + '', |
|
| 172 | + array(), |
|
| 173 | + array(), |
|
| 174 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
| 175 | 175 | array( EE_ADMIN . '*.core.php' ) |
| 176 | 176 | ) |
| 177 | 177 | ); |
@@ -179,10 +179,10 @@ discard block |
||
| 179 | 179 | // $this->CoffeeShop->addRecipe( |
| 180 | 180 | // new Recipe( |
| 181 | 181 | // '*_Admin_Page', |
| 182 | - // '', |
|
| 183 | - // array(), |
|
| 184 | - // array(), |
|
| 185 | - // CoffeeMaker::BREW_SHARED, |
|
| 182 | + // '', |
|
| 183 | + // array(), |
|
| 184 | + // array(), |
|
| 185 | + // CoffeeMaker::BREW_SHARED, |
|
| 186 | 186 | // array( |
| 187 | 187 | // EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php', |
| 188 | 188 | // ) |
@@ -192,26 +192,26 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | |
| 194 | 194 | |
| 195 | - /** |
|
| 196 | - * bootstrap EE and the request stack |
|
| 197 | - * |
|
| 198 | - * @throws ServiceNotFoundException |
|
| 199 | - * @throws InvalidClassException |
|
| 200 | - * @throws InvalidDataTypeException |
|
| 201 | - * @throws InvalidIdentifierException |
|
| 202 | - * @throws exceptions\ServiceExistsException |
|
| 203 | - * @throws OutOfBoundsException |
|
| 204 | - * @throws exceptions\InstantiationException |
|
| 205 | - */ |
|
| 206 | - public function firstBrew() |
|
| 207 | - { |
|
| 208 | - $this->CoffeeShop->brew( |
|
| 209 | - 'EventEspresso\core\services\request\Request', |
|
| 210 | - array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
| 211 | - ); |
|
| 212 | - $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
| 213 | - $this->CoffeeShop->brew('EE_Bootstrap'); |
|
| 214 | - } |
|
| 195 | + /** |
|
| 196 | + * bootstrap EE and the request stack |
|
| 197 | + * |
|
| 198 | + * @throws ServiceNotFoundException |
|
| 199 | + * @throws InvalidClassException |
|
| 200 | + * @throws InvalidDataTypeException |
|
| 201 | + * @throws InvalidIdentifierException |
|
| 202 | + * @throws exceptions\ServiceExistsException |
|
| 203 | + * @throws OutOfBoundsException |
|
| 204 | + * @throws exceptions\InstantiationException |
|
| 205 | + */ |
|
| 206 | + public function firstBrew() |
|
| 207 | + { |
|
| 208 | + $this->CoffeeShop->brew( |
|
| 209 | + 'EventEspresso\core\services\request\Request', |
|
| 210 | + array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
| 211 | + ); |
|
| 212 | + $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
| 213 | + $this->CoffeeShop->brew('EE_Bootstrap'); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | 217 | } |
@@ -132,8 +132,8 @@ discard block |
||
| 132 | 132 | array(), |
| 133 | 133 | CoffeeMaker::BREW_LOAD_ONLY, |
| 134 | 134 | array( |
| 135 | - EE_INTERFACES . '*.php', |
|
| 136 | - EE_INTERFACES . '*.interfaces.php', |
|
| 135 | + EE_INTERFACES.'*.php', |
|
| 136 | + EE_INTERFACES.'*.interfaces.php', |
|
| 137 | 137 | ) |
| 138 | 138 | ) |
| 139 | 139 | ); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | array(), |
| 146 | 146 | array(), |
| 147 | 147 | CoffeeMaker::BREW_SHARED, |
| 148 | - EE_MODELS . '*.model.php' |
|
| 148 | + EE_MODELS.'*.model.php' |
|
| 149 | 149 | ) |
| 150 | 150 | ); |
| 151 | 151 | // add a wildcard recipe for loading core classes |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | array(), |
| 158 | 158 | CoffeeMaker::BREW_SHARED, |
| 159 | 159 | array( |
| 160 | - EE_CORE . '*.core.php', |
|
| 161 | - EE_ADMIN . '*.core.php', |
|
| 162 | - EE_CPTS . '*.core.php', |
|
| 163 | - EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
|
| 160 | + EE_CORE.'*.core.php', |
|
| 161 | + EE_ADMIN.'*.core.php', |
|
| 162 | + EE_CPTS.'*.core.php', |
|
| 163 | + EE_CORE.'data_migration_scripts'.DS.'*.core.php', |
|
| 164 | 164 | ) |
| 165 | 165 | ) |
| 166 | 166 | ); |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | array(), |
| 173 | 173 | array(), |
| 174 | 174 | CoffeeMaker::BREW_LOAD_ONLY, |
| 175 | - array( EE_ADMIN . '*.core.php' ) |
|
| 175 | + array(EE_ADMIN.'*.core.php') |
|
| 176 | 176 | ) |
| 177 | 177 | ); |
| 178 | 178 | // add a wildcard recipe for loading core classes |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use EventEspresso\core\services\container\exceptions\InstantiationException; |
| 7 | 7 | |
| 8 | 8 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 9 | - exit('No direct script access allowed'); |
|
| 9 | + exit('No direct script access allowed'); |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
@@ -23,165 +23,165 @@ discard block |
||
| 23 | 23 | abstract class CoffeeMaker implements CoffeeMakerInterface |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Indicates that CoffeeMaker should construct a NEW entity instance from the provided arguments (if given) |
|
| 28 | - */ |
|
| 29 | - const BREW_NEW = 'new'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Indicates that CoffeeMaker should always return a SHARED instance |
|
| 33 | - */ |
|
| 34 | - const BREW_SHARED = 'shared'; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * Indicates that CoffeeMaker should only load the file/class/interface but NOT instantiate |
|
| 38 | - */ |
|
| 39 | - const BREW_LOAD_ONLY = 'load_only'; |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var CoffeePotInterface $coffee_pot |
|
| 44 | - */ |
|
| 45 | - private $coffee_pot; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var DependencyInjector $injector |
|
| 49 | - */ |
|
| 50 | - private $injector; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public static function getTypes() |
|
| 58 | - { |
|
| 59 | - return (array)apply_filters( |
|
| 60 | - 'FHEE__EventEspresso\core\services\container\CoffeeMaker__getTypes', |
|
| 61 | - array( |
|
| 62 | - CoffeeMaker::BREW_NEW, |
|
| 63 | - CoffeeMaker::BREW_SHARED, |
|
| 64 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
| 65 | - ) |
|
| 66 | - ); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param $type |
|
| 73 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 74 | - */ |
|
| 75 | - public static function validateType($type) |
|
| 76 | - { |
|
| 77 | - $types = CoffeeMaker::getTypes(); |
|
| 78 | - if ( ! in_array($type, $types, true)) { |
|
| 79 | - throw new InvalidIdentifierException( |
|
| 80 | - is_object($type) ? get_class($type) : gettype($type), |
|
| 81 | - __( |
|
| 82 | - 'recipe type (one of the class constants on \EventEspresso\core\services\container\CoffeeMaker)', |
|
| 83 | - 'event_espresso' |
|
| 84 | - ) |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - return $type; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * CoffeeMaker constructor. |
|
| 94 | - * |
|
| 95 | - * @param CoffeePotInterface $coffee_pot |
|
| 96 | - * @param InjectorInterface $injector |
|
| 97 | - */ |
|
| 98 | - public function __construct(CoffeePotInterface $coffee_pot, InjectorInterface $injector) |
|
| 99 | - { |
|
| 100 | - $this->coffee_pot = $coffee_pot; |
|
| 101 | - $this->injector = $injector; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return \EventEspresso\core\services\container\CoffeePotInterface |
|
| 108 | - */ |
|
| 109 | - protected function coffeePot() |
|
| 110 | - { |
|
| 111 | - return $this->coffee_pot; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * @return \EventEspresso\core\services\container\DependencyInjector |
|
| 118 | - */ |
|
| 119 | - protected function injector() |
|
| 120 | - { |
|
| 121 | - return $this->injector; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Examines the constructor to determine which method should be used for instantiation |
|
| 128 | - * |
|
| 129 | - * @param \ReflectionClass $reflector |
|
| 130 | - * @return mixed |
|
| 131 | - * @throws InstantiationException |
|
| 132 | - */ |
|
| 133 | - protected function resolveInstantiationMethod(\ReflectionClass $reflector) |
|
| 134 | - { |
|
| 135 | - if ($reflector->getConstructor() === null) { |
|
| 136 | - return 'NewInstance'; |
|
| 137 | - } |
|
| 138 | - if ($reflector->isInstantiable()) { |
|
| 139 | - return 'NewInstanceArgs'; |
|
| 140 | - } |
|
| 141 | - if (method_exists($reflector->getName(), 'instance')) { |
|
| 142 | - return 'instance'; |
|
| 143 | - } |
|
| 144 | - if (method_exists($reflector->getName(), 'new_instance')) { |
|
| 145 | - return 'new_instance'; |
|
| 146 | - } |
|
| 147 | - if (method_exists($reflector->getName(), 'new_instance_from_db')) { |
|
| 148 | - return 'new_instance_from_db'; |
|
| 149 | - } |
|
| 150 | - throw new InstantiationException($reflector->getName()); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * Ensures files for classes that are not PSR-4 compatible are loaded |
|
| 157 | - * and then verifies that classes exist where applicable |
|
| 158 | - * |
|
| 159 | - * @param RecipeInterface $recipe |
|
| 160 | - * @return bool |
|
| 161 | - * @throws InvalidClassException |
|
| 162 | - */ |
|
| 163 | - protected function resolveClassAndFilepath(RecipeInterface $recipe) |
|
| 164 | - { |
|
| 165 | - $paths = $recipe->paths(); |
|
| 166 | - if ( ! empty($paths)) { |
|
| 167 | - foreach ($paths as $path) { |
|
| 168 | - if (strpos($path, '*') === false && is_readable($path)) { |
|
| 169 | - require_once($path); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - // re: using "false" for class_exists() second param: |
|
| 174 | - // if a class name is not already known to PHP, then class_exists() will run through |
|
| 175 | - // all of the registered spl_autoload functions until it either finds the class, |
|
| 176 | - // or gets to the end of the registered spl_autoload functions. |
|
| 177 | - // When the second parameter is true, it will also attempt to load the class file, |
|
| 178 | - // but it will also trigger an error if the class can not be loaded. |
|
| 179 | - // We don't want that extra error in the mix, so we have set the second param to "false" |
|
| 180 | - if ($recipe->type() !== CoffeeMaker::BREW_LOAD_ONLY && ! class_exists($recipe->fqcn(), false)) { |
|
| 181 | - throw new InvalidClassException($recipe->identifier()); |
|
| 182 | - } |
|
| 183 | - return true; |
|
| 184 | - } |
|
| 26 | + /** |
|
| 27 | + * Indicates that CoffeeMaker should construct a NEW entity instance from the provided arguments (if given) |
|
| 28 | + */ |
|
| 29 | + const BREW_NEW = 'new'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Indicates that CoffeeMaker should always return a SHARED instance |
|
| 33 | + */ |
|
| 34 | + const BREW_SHARED = 'shared'; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * Indicates that CoffeeMaker should only load the file/class/interface but NOT instantiate |
|
| 38 | + */ |
|
| 39 | + const BREW_LOAD_ONLY = 'load_only'; |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var CoffeePotInterface $coffee_pot |
|
| 44 | + */ |
|
| 45 | + private $coffee_pot; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var DependencyInjector $injector |
|
| 49 | + */ |
|
| 50 | + private $injector; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public static function getTypes() |
|
| 58 | + { |
|
| 59 | + return (array)apply_filters( |
|
| 60 | + 'FHEE__EventEspresso\core\services\container\CoffeeMaker__getTypes', |
|
| 61 | + array( |
|
| 62 | + CoffeeMaker::BREW_NEW, |
|
| 63 | + CoffeeMaker::BREW_SHARED, |
|
| 64 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
| 65 | + ) |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param $type |
|
| 73 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 74 | + */ |
|
| 75 | + public static function validateType($type) |
|
| 76 | + { |
|
| 77 | + $types = CoffeeMaker::getTypes(); |
|
| 78 | + if ( ! in_array($type, $types, true)) { |
|
| 79 | + throw new InvalidIdentifierException( |
|
| 80 | + is_object($type) ? get_class($type) : gettype($type), |
|
| 81 | + __( |
|
| 82 | + 'recipe type (one of the class constants on \EventEspresso\core\services\container\CoffeeMaker)', |
|
| 83 | + 'event_espresso' |
|
| 84 | + ) |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + return $type; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * CoffeeMaker constructor. |
|
| 94 | + * |
|
| 95 | + * @param CoffeePotInterface $coffee_pot |
|
| 96 | + * @param InjectorInterface $injector |
|
| 97 | + */ |
|
| 98 | + public function __construct(CoffeePotInterface $coffee_pot, InjectorInterface $injector) |
|
| 99 | + { |
|
| 100 | + $this->coffee_pot = $coffee_pot; |
|
| 101 | + $this->injector = $injector; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return \EventEspresso\core\services\container\CoffeePotInterface |
|
| 108 | + */ |
|
| 109 | + protected function coffeePot() |
|
| 110 | + { |
|
| 111 | + return $this->coffee_pot; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * @return \EventEspresso\core\services\container\DependencyInjector |
|
| 118 | + */ |
|
| 119 | + protected function injector() |
|
| 120 | + { |
|
| 121 | + return $this->injector; |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Examines the constructor to determine which method should be used for instantiation |
|
| 128 | + * |
|
| 129 | + * @param \ReflectionClass $reflector |
|
| 130 | + * @return mixed |
|
| 131 | + * @throws InstantiationException |
|
| 132 | + */ |
|
| 133 | + protected function resolveInstantiationMethod(\ReflectionClass $reflector) |
|
| 134 | + { |
|
| 135 | + if ($reflector->getConstructor() === null) { |
|
| 136 | + return 'NewInstance'; |
|
| 137 | + } |
|
| 138 | + if ($reflector->isInstantiable()) { |
|
| 139 | + return 'NewInstanceArgs'; |
|
| 140 | + } |
|
| 141 | + if (method_exists($reflector->getName(), 'instance')) { |
|
| 142 | + return 'instance'; |
|
| 143 | + } |
|
| 144 | + if (method_exists($reflector->getName(), 'new_instance')) { |
|
| 145 | + return 'new_instance'; |
|
| 146 | + } |
|
| 147 | + if (method_exists($reflector->getName(), 'new_instance_from_db')) { |
|
| 148 | + return 'new_instance_from_db'; |
|
| 149 | + } |
|
| 150 | + throw new InstantiationException($reflector->getName()); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * Ensures files for classes that are not PSR-4 compatible are loaded |
|
| 157 | + * and then verifies that classes exist where applicable |
|
| 158 | + * |
|
| 159 | + * @param RecipeInterface $recipe |
|
| 160 | + * @return bool |
|
| 161 | + * @throws InvalidClassException |
|
| 162 | + */ |
|
| 163 | + protected function resolveClassAndFilepath(RecipeInterface $recipe) |
|
| 164 | + { |
|
| 165 | + $paths = $recipe->paths(); |
|
| 166 | + if ( ! empty($paths)) { |
|
| 167 | + foreach ($paths as $path) { |
|
| 168 | + if (strpos($path, '*') === false && is_readable($path)) { |
|
| 169 | + require_once($path); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + // re: using "false" for class_exists() second param: |
|
| 174 | + // if a class name is not already known to PHP, then class_exists() will run through |
|
| 175 | + // all of the registered spl_autoload functions until it either finds the class, |
|
| 176 | + // or gets to the end of the registered spl_autoload functions. |
|
| 177 | + // When the second parameter is true, it will also attempt to load the class file, |
|
| 178 | + // but it will also trigger an error if the class can not be loaded. |
|
| 179 | + // We don't want that extra error in the mix, so we have set the second param to "false" |
|
| 180 | + if ($recipe->type() !== CoffeeMaker::BREW_LOAD_ONLY && ! class_exists($recipe->fqcn(), false)) { |
|
| 181 | + throw new InvalidClassException($recipe->identifier()); |
|
| 182 | + } |
|
| 183 | + return true; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | 186 | |
| 187 | 187 | |
@@ -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); |
@@ -29,81 +29,81 @@ |
||
| 29 | 29 | class BootstrapRequestResponseObjects |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @type LegacyRequestInterface $legacy_request |
|
| 34 | - */ |
|
| 35 | - protected $legacy_request; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @type LoaderInterface $loader |
|
| 39 | - */ |
|
| 40 | - protected $loader; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * @var RequestInterface $request |
|
| 44 | - */ |
|
| 45 | - protected $request; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * @var ResponseInterface $response |
|
| 49 | - */ |
|
| 50 | - protected $response; |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * BootstrapRequestResponseObjects constructor. |
|
| 55 | - * |
|
| 56 | - * @param LoaderInterface $loader |
|
| 57 | - */ |
|
| 58 | - public function __construct(LoaderInterface $loader) |
|
| 59 | - { |
|
| 60 | - $this->loader = $loader; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @return void |
|
| 66 | - */ |
|
| 67 | - public function buildRequestResponse() |
|
| 68 | - { |
|
| 69 | - // load our Request and Response objects |
|
| 70 | - $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 71 | - $this->response = new Response(); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @return void |
|
| 77 | - * @throws InvalidArgumentException |
|
| 78 | - */ |
|
| 79 | - public function shareRequestResponse() |
|
| 80 | - { |
|
| 81 | - $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
| 82 | - $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
| 83 | - EE_Dependency_Map::instance()->setRequest($this->request); |
|
| 84 | - EE_Dependency_Map::instance()->setResponse($this->response); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @return void |
|
| 90 | - * @throws InvalidArgumentException |
|
| 91 | - * @throws EE_Error |
|
| 92 | - */ |
|
| 93 | - public function setupLegacyRequest() |
|
| 94 | - { |
|
| 95 | - espresso_load_required( |
|
| 96 | - 'EE_Request', |
|
| 97 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 98 | - ); |
|
| 99 | - $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 100 | - $this->legacy_request->setRequest($this->request); |
|
| 101 | - $this->legacy_request->admin = $this->request->isAdmin(); |
|
| 102 | - $this->legacy_request->ajax = $this->request->isAjax(); |
|
| 103 | - $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
| 104 | - EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
| 105 | - $this->loader->share('EE_Request', $this->legacy_request); |
|
| 106 | - $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
| 107 | - } |
|
| 32 | + /** |
|
| 33 | + * @type LegacyRequestInterface $legacy_request |
|
| 34 | + */ |
|
| 35 | + protected $legacy_request; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @type LoaderInterface $loader |
|
| 39 | + */ |
|
| 40 | + protected $loader; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * @var RequestInterface $request |
|
| 44 | + */ |
|
| 45 | + protected $request; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * @var ResponseInterface $response |
|
| 49 | + */ |
|
| 50 | + protected $response; |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * BootstrapRequestResponseObjects constructor. |
|
| 55 | + * |
|
| 56 | + * @param LoaderInterface $loader |
|
| 57 | + */ |
|
| 58 | + public function __construct(LoaderInterface $loader) |
|
| 59 | + { |
|
| 60 | + $this->loader = $loader; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @return void |
|
| 66 | + */ |
|
| 67 | + public function buildRequestResponse() |
|
| 68 | + { |
|
| 69 | + // load our Request and Response objects |
|
| 70 | + $this->request = new Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 71 | + $this->response = new Response(); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @return void |
|
| 77 | + * @throws InvalidArgumentException |
|
| 78 | + */ |
|
| 79 | + public function shareRequestResponse() |
|
| 80 | + { |
|
| 81 | + $this->loader->share('EventEspresso\core\services\request\Request', $this->request); |
|
| 82 | + $this->loader->share('EventEspresso\core\services\request\Response', $this->response); |
|
| 83 | + EE_Dependency_Map::instance()->setRequest($this->request); |
|
| 84 | + EE_Dependency_Map::instance()->setResponse($this->response); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @return void |
|
| 90 | + * @throws InvalidArgumentException |
|
| 91 | + * @throws EE_Error |
|
| 92 | + */ |
|
| 93 | + public function setupLegacyRequest() |
|
| 94 | + { |
|
| 95 | + espresso_load_required( |
|
| 96 | + 'EE_Request', |
|
| 97 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 98 | + ); |
|
| 99 | + $this->legacy_request = new EE_Request($_GET, $_POST, $_COOKIE, $_SERVER); |
|
| 100 | + $this->legacy_request->setRequest($this->request); |
|
| 101 | + $this->legacy_request->admin = $this->request->isAdmin(); |
|
| 102 | + $this->legacy_request->ajax = $this->request->isAjax(); |
|
| 103 | + $this->legacy_request->front_ajax = $this->request->isFrontAjax(); |
|
| 104 | + EE_Dependency_Map::instance()->setLegacyRequest($this->legacy_request); |
|
| 105 | + $this->loader->share('EE_Request', $this->legacy_request); |
|
| 106 | + $this->loader->share('EventEspresso\core\services\request\LegacyRequestInterface', $this->legacy_request); |
|
| 107 | + } |
|
| 108 | 108 | } |
| 109 | 109 | |
@@ -67,13 +67,13 @@ |
||
| 67 | 67 | // EE_Dependency_Map: info about how to load classes required by other classes |
| 68 | 68 | espresso_load_required( |
| 69 | 69 | 'EE_Dependency_Map', |
| 70 | - EE_CORE . 'EE_Dependency_Map.core.php' |
|
| 70 | + EE_CORE.'EE_Dependency_Map.core.php' |
|
| 71 | 71 | ); |
| 72 | 72 | $this->dependency_map = EE_Dependency_Map::instance(); |
| 73 | 73 | // EE_Registry: central repository for classes (legacy) |
| 74 | 74 | espresso_load_required( |
| 75 | 75 | 'EE_Registry', |
| 76 | - EE_CORE . 'EE_Registry.core.php' |
|
| 76 | + EE_CORE.'EE_Registry.core.php' |
|
| 77 | 77 | ); |
| 78 | 78 | $this->registry = EE_Registry::instance($this->dependency_map); |
| 79 | 79 | } |
@@ -26,98 +26,98 @@ |
||
| 26 | 26 | class BootstrapDependencyInjectionContainer |
| 27 | 27 | { |
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var EE_Dependency_Map $dependency_map |
|
| 31 | - */ |
|
| 32 | - protected $dependency_map; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @type LoaderInterface $loader |
|
| 36 | - */ |
|
| 37 | - protected $loader; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var EE_Registry $registry |
|
| 41 | - */ |
|
| 42 | - protected $registry; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
| 47 | - */ |
|
| 48 | - public function buildDependencyInjectionContainer() |
|
| 49 | - { |
|
| 50 | - // build DI container |
|
| 51 | - // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 52 | - // $OpenCoffeeShop->addRecipes(); |
|
| 53 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Setups EE_Registry and EE_Dependency_Map |
|
| 59 | - * |
|
| 60 | - * @throws EE_Error |
|
| 61 | - * @throws InvalidDataTypeException |
|
| 62 | - * @throws InvalidInterfaceException |
|
| 63 | - * @throws InvalidArgumentException |
|
| 64 | - */ |
|
| 65 | - public function buildLegacyDependencyInjectionContainer() |
|
| 66 | - { |
|
| 67 | - // EE_Dependency_Map: info about how to load classes required by other classes |
|
| 68 | - espresso_load_required( |
|
| 69 | - 'EE_Dependency_Map', |
|
| 70 | - EE_CORE . 'EE_Dependency_Map.core.php' |
|
| 71 | - ); |
|
| 72 | - $this->dependency_map = EE_Dependency_Map::instance(); |
|
| 73 | - // EE_Registry: central repository for classes (legacy) |
|
| 74 | - espresso_load_required( |
|
| 75 | - 'EE_Registry', |
|
| 76 | - EE_CORE . 'EE_Registry.core.php' |
|
| 77 | - ); |
|
| 78 | - $this->registry = EE_Registry::instance($this->dependency_map); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Performs initial setup for the generic Loader |
|
| 84 | - * |
|
| 85 | - * @throws InvalidDataTypeException |
|
| 86 | - * @throws InvalidInterfaceException |
|
| 87 | - * @throws InvalidArgumentException |
|
| 88 | - */ |
|
| 89 | - public function buildLoader() |
|
| 90 | - { |
|
| 91 | - $this->loader = LoaderFactory::getLoader($this->registry); |
|
| 92 | - $this->dependency_map->setLoader($this->loader); |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @return EE_Dependency_Map |
|
| 98 | - */ |
|
| 99 | - public function getDependencyMap() |
|
| 100 | - { |
|
| 101 | - return $this->dependency_map; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @return EE_Registry |
|
| 107 | - */ |
|
| 108 | - public function getRegistry() |
|
| 109 | - { |
|
| 110 | - return $this->registry; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * @return LoaderInterface |
|
| 117 | - */ |
|
| 118 | - public function getLoader() |
|
| 119 | - { |
|
| 120 | - return $this->loader; |
|
| 121 | - } |
|
| 29 | + /** |
|
| 30 | + * @var EE_Dependency_Map $dependency_map |
|
| 31 | + */ |
|
| 32 | + protected $dependency_map; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @type LoaderInterface $loader |
|
| 36 | + */ |
|
| 37 | + protected $loader; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var EE_Registry $registry |
|
| 41 | + */ |
|
| 42 | + protected $registry; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * Can't use this just yet until we exorcise some more of our singleton usage from core |
|
| 47 | + */ |
|
| 48 | + public function buildDependencyInjectionContainer() |
|
| 49 | + { |
|
| 50 | + // build DI container |
|
| 51 | + // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 52 | + // $OpenCoffeeShop->addRecipes(); |
|
| 53 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Setups EE_Registry and EE_Dependency_Map |
|
| 59 | + * |
|
| 60 | + * @throws EE_Error |
|
| 61 | + * @throws InvalidDataTypeException |
|
| 62 | + * @throws InvalidInterfaceException |
|
| 63 | + * @throws InvalidArgumentException |
|
| 64 | + */ |
|
| 65 | + public function buildLegacyDependencyInjectionContainer() |
|
| 66 | + { |
|
| 67 | + // EE_Dependency_Map: info about how to load classes required by other classes |
|
| 68 | + espresso_load_required( |
|
| 69 | + 'EE_Dependency_Map', |
|
| 70 | + EE_CORE . 'EE_Dependency_Map.core.php' |
|
| 71 | + ); |
|
| 72 | + $this->dependency_map = EE_Dependency_Map::instance(); |
|
| 73 | + // EE_Registry: central repository for classes (legacy) |
|
| 74 | + espresso_load_required( |
|
| 75 | + 'EE_Registry', |
|
| 76 | + EE_CORE . 'EE_Registry.core.php' |
|
| 77 | + ); |
|
| 78 | + $this->registry = EE_Registry::instance($this->dependency_map); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Performs initial setup for the generic Loader |
|
| 84 | + * |
|
| 85 | + * @throws InvalidDataTypeException |
|
| 86 | + * @throws InvalidInterfaceException |
|
| 87 | + * @throws InvalidArgumentException |
|
| 88 | + */ |
|
| 89 | + public function buildLoader() |
|
| 90 | + { |
|
| 91 | + $this->loader = LoaderFactory::getLoader($this->registry); |
|
| 92 | + $this->dependency_map->setLoader($this->loader); |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @return EE_Dependency_Map |
|
| 98 | + */ |
|
| 99 | + public function getDependencyMap() |
|
| 100 | + { |
|
| 101 | + return $this->dependency_map; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @return EE_Registry |
|
| 107 | + */ |
|
| 108 | + public function getRegistry() |
|
| 109 | + { |
|
| 110 | + return $this->registry; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * @return LoaderInterface |
|
| 117 | + */ |
|
| 118 | + public function getLoader() |
|
| 119 | + { |
|
| 120 | + return $this->loader; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | 123 | } |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | * @param EE_Response $response |
| 20 | 20 | * @return EE_Response |
| 21 | 21 | */ |
| 22 | - public function handle_request( EE_Request $request, EE_Response $response ) { |
|
| 22 | + public function handle_request(EE_Request $request, EE_Response $response) { |
|
| 23 | 23 | $this->_request = $request; |
| 24 | 24 | $this->_response = $response; |
| 25 | 25 | $this->display_alpha_banner_warning(); |
| 26 | - $this->_response = $this->process_request_stack( $this->_request, $this->_response ); |
|
| 26 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
| 27 | 27 | return $this->_response; |
| 28 | 28 | } |
| 29 | 29 | |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | - * @deprecated 4.9.53 |
|
| 17 | + * @deprecated 4.9.53 |
|
| 18 | 18 | * @param EE_Request $request |
| 19 | 19 | * @param EE_Response $response |
| 20 | 20 | * @return EE_Response |
@@ -30,71 +30,71 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | - * @deprecated |
|
| 34 | - * @return string |
|
| 33 | + * @deprecated |
|
| 34 | + * @return string |
|
| 35 | 35 | */ |
| 36 | 36 | public function display_alpha_banner_warning() { |
| 37 | - EE_Error::doing_it_wrong( |
|
| 38 | - __METHOD__, |
|
| 39 | - sprintf( |
|
| 40 | - esc_html__( |
|
| 41 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 42 | - 'event_espresso' |
|
| 43 | - ), |
|
| 44 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()', |
|
| 45 | - '\core\services\request', |
|
| 46 | - 'EventEspresso\core\services\request' |
|
| 47 | - ), |
|
| 48 | - '4.9.52', |
|
| 49 | - '4.10.0' |
|
| 50 | - ); |
|
| 51 | - } |
|
| 37 | + EE_Error::doing_it_wrong( |
|
| 38 | + __METHOD__, |
|
| 39 | + sprintf( |
|
| 40 | + esc_html__( |
|
| 41 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 42 | + 'event_espresso' |
|
| 43 | + ), |
|
| 44 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()', |
|
| 45 | + '\core\services\request', |
|
| 46 | + 'EventEspresso\core\services\request' |
|
| 47 | + ), |
|
| 48 | + '4.9.52', |
|
| 49 | + '4.10.0' |
|
| 50 | + ); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | - * @deprecated |
|
| 57 | - * @return void |
|
| 56 | + * @deprecated |
|
| 57 | + * @return void |
|
| 58 | 58 | */ |
| 59 | 59 | public function alpha_banner_admin_notice() { |
| 60 | - EE_Error::doing_it_wrong( |
|
| 61 | - __METHOD__, |
|
| 62 | - sprintf( |
|
| 63 | - esc_html__( |
|
| 64 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 65 | - 'event_espresso' |
|
| 66 | - ), |
|
| 67 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()', |
|
| 68 | - '\core\services\request', |
|
| 69 | - 'EventEspresso\core\services\request' |
|
| 70 | - ), |
|
| 71 | - '4.9.52', |
|
| 72 | - '4.10.0' |
|
| 73 | - ); |
|
| 74 | - } |
|
| 60 | + EE_Error::doing_it_wrong( |
|
| 61 | + __METHOD__, |
|
| 62 | + sprintf( |
|
| 63 | + esc_html__( |
|
| 64 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 65 | + 'event_espresso' |
|
| 66 | + ), |
|
| 67 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()', |
|
| 68 | + '\core\services\request', |
|
| 69 | + 'EventEspresso\core\services\request' |
|
| 70 | + ), |
|
| 71 | + '4.9.52', |
|
| 72 | + '4.10.0' |
|
| 73 | + ); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * @deprecated |
|
| 80 | - * @return void |
|
| 79 | + * @deprecated |
|
| 80 | + * @return void |
|
| 81 | 81 | */ |
| 82 | 82 | public function alpha_banner_warning_notice() { |
| 83 | - EE_Error::doing_it_wrong( |
|
| 84 | - __METHOD__, |
|
| 85 | - sprintf( |
|
| 86 | - esc_html__( |
|
| 87 | - 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 88 | - 'event_espresso' |
|
| 89 | - ), |
|
| 90 | - 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()', |
|
| 91 | - '\core\services\request', |
|
| 92 | - 'EventEspresso\core\services\request' |
|
| 93 | - ), |
|
| 94 | - '4.9.52', |
|
| 95 | - '4.10.0' |
|
| 96 | - ); |
|
| 97 | - } |
|
| 83 | + EE_Error::doing_it_wrong( |
|
| 84 | + __METHOD__, |
|
| 85 | + sprintf( |
|
| 86 | + esc_html__( |
|
| 87 | + 'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 88 | + 'event_espresso' |
|
| 89 | + ), |
|
| 90 | + 'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()', |
|
| 91 | + '\core\services\request', |
|
| 92 | + 'EventEspresso\core\services\request' |
|
| 93 | + ), |
|
| 94 | + '4.9.52', |
|
| 95 | + '4.10.0' |
|
| 96 | + ); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | } |
@@ -22,327 +22,327 @@ |
||
| 22 | 22 | class EE_Request implements LegacyRequestInterface, InterminableInterface |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var RequestInterface $request |
|
| 27 | - */ |
|
| 28 | - private $request; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * whether current request is for the admin but NOT via AJAX |
|
| 32 | - * |
|
| 33 | - * @var boolean $admin |
|
| 34 | - */ |
|
| 35 | - public $admin = false; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * whether current request is via AJAX |
|
| 39 | - * |
|
| 40 | - * @var boolean $ajax |
|
| 41 | - */ |
|
| 42 | - public $ajax = false; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * whether current request is via AJAX from the frontend of the site |
|
| 46 | - * |
|
| 47 | - * @var boolean $front_ajax |
|
| 48 | - */ |
|
| 49 | - public $front_ajax = false; |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @deprecated 4.9.53 |
|
| 54 | - * @param array $get |
|
| 55 | - * @param array $post |
|
| 56 | - * @param array $cookie |
|
| 57 | - * @param array $server |
|
| 58 | - */ |
|
| 59 | - public function __construct(array $get, array $post, array $cookie, 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 | - /** |
|
| 92 | - * @deprecated 4.9.53 |
|
| 93 | - * @return array |
|
| 94 | - * @throws InvalidArgumentException |
|
| 95 | - * @throws InvalidDataTypeException |
|
| 96 | - * @throws InvalidInterfaceException |
|
| 97 | - */ |
|
| 98 | - public function get_params() |
|
| 99 | - { |
|
| 100 | - return $this->request()->getParams(); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * @deprecated 4.9.53 |
|
| 107 | - * @return array |
|
| 108 | - * @throws InvalidArgumentException |
|
| 109 | - * @throws InvalidDataTypeException |
|
| 110 | - * @throws InvalidInterfaceException |
|
| 111 | - */ |
|
| 112 | - public function post_params() |
|
| 113 | - { |
|
| 114 | - return $this->request()->postParams(); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @deprecated 4.9.53 |
|
| 121 | - * @return array |
|
| 122 | - * @throws InvalidArgumentException |
|
| 123 | - * @throws InvalidDataTypeException |
|
| 124 | - * @throws InvalidInterfaceException |
|
| 125 | - */ |
|
| 126 | - public function cookie_params() |
|
| 127 | - { |
|
| 128 | - return $this->request()->cookieParams(); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * @deprecated 4.9.53 |
|
| 134 | - * @return array |
|
| 135 | - * @throws InvalidArgumentException |
|
| 136 | - * @throws InvalidDataTypeException |
|
| 137 | - * @throws InvalidInterfaceException |
|
| 138 | - */ |
|
| 139 | - public function server_params() |
|
| 140 | - { |
|
| 141 | - return $this->request()->serverParams(); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * returns contents of $_REQUEST |
|
| 148 | - * |
|
| 149 | - * @deprecated 4.9.53 |
|
| 150 | - * @return array |
|
| 151 | - * @throws InvalidArgumentException |
|
| 152 | - * @throws InvalidDataTypeException |
|
| 153 | - * @throws InvalidInterfaceException |
|
| 154 | - */ |
|
| 155 | - public function params() |
|
| 156 | - { |
|
| 157 | - return $this->request()->requestParams(); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * @deprecated 4.9.53 |
|
| 164 | - * @param $key |
|
| 165 | - * @param $value |
|
| 166 | - * @param bool $override_ee |
|
| 167 | - * @return void |
|
| 168 | - * @throws InvalidArgumentException |
|
| 169 | - * @throws InvalidDataTypeException |
|
| 170 | - * @throws InvalidInterfaceException |
|
| 171 | - */ |
|
| 172 | - public function set($key, $value, $override_ee = false) |
|
| 173 | - { |
|
| 174 | - $this->request()->setRequestParam($key, $value, $override_ee); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - |
|
| 179 | - /** |
|
| 180 | - * returns the value for a request param if the given key exists |
|
| 181 | - * |
|
| 182 | - * @deprecated 4.9.53 |
|
| 183 | - * @param $key |
|
| 184 | - * @param null $default |
|
| 185 | - * @return mixed |
|
| 186 | - * @throws InvalidArgumentException |
|
| 187 | - * @throws InvalidDataTypeException |
|
| 188 | - * @throws InvalidInterfaceException |
|
| 189 | - */ |
|
| 190 | - public function get($key, $default = null) |
|
| 191 | - { |
|
| 192 | - return $this->request()->getRequestParam($key, $default); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * check if param exists |
|
| 199 | - * |
|
| 200 | - * @deprecated 4.9.53 |
|
| 201 | - * @param $key |
|
| 202 | - * @return bool |
|
| 203 | - * @throws InvalidArgumentException |
|
| 204 | - * @throws InvalidDataTypeException |
|
| 205 | - * @throws InvalidInterfaceException |
|
| 206 | - */ |
|
| 207 | - public function is_set($key) |
|
| 208 | - { |
|
| 209 | - return $this->request()->requestParamIsSet($key); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - /** |
|
| 215 | - * remove param |
|
| 216 | - * |
|
| 217 | - * @deprecated 4.9.53 |
|
| 218 | - * @param $key |
|
| 219 | - * @param bool $unset_from_global_too |
|
| 220 | - * @throws InvalidArgumentException |
|
| 221 | - * @throws InvalidDataTypeException |
|
| 222 | - * @throws InvalidInterfaceException |
|
| 223 | - */ |
|
| 224 | - public function un_set($key, $unset_from_global_too = false) |
|
| 225 | - { |
|
| 226 | - $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * @deprecated 4.9.53 |
|
| 233 | - * @return string |
|
| 234 | - * @throws InvalidArgumentException |
|
| 235 | - * @throws InvalidDataTypeException |
|
| 236 | - * @throws InvalidInterfaceException |
|
| 237 | - */ |
|
| 238 | - public function ip_address() |
|
| 239 | - { |
|
| 240 | - return $this->request()->ipAddress(); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - /** |
|
| 245 | - * @deprecated 4.9.53 |
|
| 246 | - * @return bool |
|
| 247 | - * @throws InvalidArgumentException |
|
| 248 | - * @throws InvalidDataTypeException |
|
| 249 | - * @throws InvalidInterfaceException |
|
| 250 | - */ |
|
| 251 | - public function isAdmin() |
|
| 252 | - { |
|
| 253 | - return $this->request()->isAdmin(); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - /** |
|
| 258 | - * @deprecated 4.9.53 |
|
| 259 | - * @return mixed |
|
| 260 | - * @throws InvalidArgumentException |
|
| 261 | - * @throws InvalidDataTypeException |
|
| 262 | - * @throws InvalidInterfaceException |
|
| 263 | - */ |
|
| 264 | - public function isAjax() |
|
| 265 | - { |
|
| 266 | - return $this->request()->isAjax(); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @deprecated 4.9.53 |
|
| 272 | - * @return mixed |
|
| 273 | - * @throws InvalidArgumentException |
|
| 274 | - * @throws InvalidDataTypeException |
|
| 275 | - * @throws InvalidInterfaceException |
|
| 276 | - */ |
|
| 277 | - public function isFrontAjax() |
|
| 278 | - { |
|
| 279 | - return $this->request()->isFrontAjax(); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * @deprecated 4.9.53 |
|
| 285 | - * @return mixed|string |
|
| 286 | - * @throws InvalidArgumentException |
|
| 287 | - * @throws InvalidDataTypeException |
|
| 288 | - * @throws InvalidInterfaceException |
|
| 289 | - */ |
|
| 290 | - public function requestUri() |
|
| 291 | - { |
|
| 292 | - return $this->request()->requestUri(); |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @deprecated 4.9.53 |
|
| 298 | - * @return string |
|
| 299 | - * @throws InvalidArgumentException |
|
| 300 | - * @throws InvalidDataTypeException |
|
| 301 | - * @throws InvalidInterfaceException |
|
| 302 | - */ |
|
| 303 | - public function userAgent() |
|
| 304 | - { |
|
| 305 | - return $this->request()->userAgent(); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * @deprecated 4.9.53 |
|
| 311 | - * @param string $user_agent |
|
| 312 | - * @throws InvalidArgumentException |
|
| 313 | - * @throws InvalidDataTypeException |
|
| 314 | - * @throws InvalidInterfaceException |
|
| 315 | - */ |
|
| 316 | - public function setUserAgent($user_agent = '') |
|
| 317 | - { |
|
| 318 | - $this->request()->setUserAgent($user_agent); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * @deprecated 4.9.53 |
|
| 324 | - * @return bool |
|
| 325 | - * @throws InvalidArgumentException |
|
| 326 | - * @throws InvalidDataTypeException |
|
| 327 | - * @throws InvalidInterfaceException |
|
| 328 | - */ |
|
| 329 | - public function isBot() |
|
| 330 | - { |
|
| 331 | - return $this->request()->isBot(); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * @deprecated 4.9.53 |
|
| 337 | - * @param bool $is_bot |
|
| 338 | - * @throws InvalidArgumentException |
|
| 339 | - * @throws InvalidDataTypeException |
|
| 340 | - * @throws InvalidInterfaceException |
|
| 341 | - */ |
|
| 342 | - public function setIsBot($is_bot) |
|
| 343 | - { |
|
| 344 | - $this->request()->setIsBot($is_bot); |
|
| 345 | - } |
|
| 25 | + /** |
|
| 26 | + * @var RequestInterface $request |
|
| 27 | + */ |
|
| 28 | + private $request; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * whether current request is for the admin but NOT via AJAX |
|
| 32 | + * |
|
| 33 | + * @var boolean $admin |
|
| 34 | + */ |
|
| 35 | + public $admin = false; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * whether current request is via AJAX |
|
| 39 | + * |
|
| 40 | + * @var boolean $ajax |
|
| 41 | + */ |
|
| 42 | + public $ajax = false; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * whether current request is via AJAX from the frontend of the site |
|
| 46 | + * |
|
| 47 | + * @var boolean $front_ajax |
|
| 48 | + */ |
|
| 49 | + public $front_ajax = false; |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @deprecated 4.9.53 |
|
| 54 | + * @param array $get |
|
| 55 | + * @param array $post |
|
| 56 | + * @param array $cookie |
|
| 57 | + * @param array $server |
|
| 58 | + */ |
|
| 59 | + public function __construct(array $get, array $post, array $cookie, 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 | + /** |
|
| 92 | + * @deprecated 4.9.53 |
|
| 93 | + * @return array |
|
| 94 | + * @throws InvalidArgumentException |
|
| 95 | + * @throws InvalidDataTypeException |
|
| 96 | + * @throws InvalidInterfaceException |
|
| 97 | + */ |
|
| 98 | + public function get_params() |
|
| 99 | + { |
|
| 100 | + return $this->request()->getParams(); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * @deprecated 4.9.53 |
|
| 107 | + * @return array |
|
| 108 | + * @throws InvalidArgumentException |
|
| 109 | + * @throws InvalidDataTypeException |
|
| 110 | + * @throws InvalidInterfaceException |
|
| 111 | + */ |
|
| 112 | + public function post_params() |
|
| 113 | + { |
|
| 114 | + return $this->request()->postParams(); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @deprecated 4.9.53 |
|
| 121 | + * @return array |
|
| 122 | + * @throws InvalidArgumentException |
|
| 123 | + * @throws InvalidDataTypeException |
|
| 124 | + * @throws InvalidInterfaceException |
|
| 125 | + */ |
|
| 126 | + public function cookie_params() |
|
| 127 | + { |
|
| 128 | + return $this->request()->cookieParams(); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * @deprecated 4.9.53 |
|
| 134 | + * @return array |
|
| 135 | + * @throws InvalidArgumentException |
|
| 136 | + * @throws InvalidDataTypeException |
|
| 137 | + * @throws InvalidInterfaceException |
|
| 138 | + */ |
|
| 139 | + public function server_params() |
|
| 140 | + { |
|
| 141 | + return $this->request()->serverParams(); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * returns contents of $_REQUEST |
|
| 148 | + * |
|
| 149 | + * @deprecated 4.9.53 |
|
| 150 | + * @return array |
|
| 151 | + * @throws InvalidArgumentException |
|
| 152 | + * @throws InvalidDataTypeException |
|
| 153 | + * @throws InvalidInterfaceException |
|
| 154 | + */ |
|
| 155 | + public function params() |
|
| 156 | + { |
|
| 157 | + return $this->request()->requestParams(); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @deprecated 4.9.53 |
|
| 164 | + * @param $key |
|
| 165 | + * @param $value |
|
| 166 | + * @param bool $override_ee |
|
| 167 | + * @return void |
|
| 168 | + * @throws InvalidArgumentException |
|
| 169 | + * @throws InvalidDataTypeException |
|
| 170 | + * @throws InvalidInterfaceException |
|
| 171 | + */ |
|
| 172 | + public function set($key, $value, $override_ee = false) |
|
| 173 | + { |
|
| 174 | + $this->request()->setRequestParam($key, $value, $override_ee); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + |
|
| 179 | + /** |
|
| 180 | + * returns the value for a request param if the given key exists |
|
| 181 | + * |
|
| 182 | + * @deprecated 4.9.53 |
|
| 183 | + * @param $key |
|
| 184 | + * @param null $default |
|
| 185 | + * @return mixed |
|
| 186 | + * @throws InvalidArgumentException |
|
| 187 | + * @throws InvalidDataTypeException |
|
| 188 | + * @throws InvalidInterfaceException |
|
| 189 | + */ |
|
| 190 | + public function get($key, $default = null) |
|
| 191 | + { |
|
| 192 | + return $this->request()->getRequestParam($key, $default); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * check if param exists |
|
| 199 | + * |
|
| 200 | + * @deprecated 4.9.53 |
|
| 201 | + * @param $key |
|
| 202 | + * @return bool |
|
| 203 | + * @throws InvalidArgumentException |
|
| 204 | + * @throws InvalidDataTypeException |
|
| 205 | + * @throws InvalidInterfaceException |
|
| 206 | + */ |
|
| 207 | + public function is_set($key) |
|
| 208 | + { |
|
| 209 | + return $this->request()->requestParamIsSet($key); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + /** |
|
| 215 | + * remove param |
|
| 216 | + * |
|
| 217 | + * @deprecated 4.9.53 |
|
| 218 | + * @param $key |
|
| 219 | + * @param bool $unset_from_global_too |
|
| 220 | + * @throws InvalidArgumentException |
|
| 221 | + * @throws InvalidDataTypeException |
|
| 222 | + * @throws InvalidInterfaceException |
|
| 223 | + */ |
|
| 224 | + public function un_set($key, $unset_from_global_too = false) |
|
| 225 | + { |
|
| 226 | + $this->request()->unSetRequestParam($key, $unset_from_global_too); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * @deprecated 4.9.53 |
|
| 233 | + * @return string |
|
| 234 | + * @throws InvalidArgumentException |
|
| 235 | + * @throws InvalidDataTypeException |
|
| 236 | + * @throws InvalidInterfaceException |
|
| 237 | + */ |
|
| 238 | + public function ip_address() |
|
| 239 | + { |
|
| 240 | + return $this->request()->ipAddress(); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + /** |
|
| 245 | + * @deprecated 4.9.53 |
|
| 246 | + * @return bool |
|
| 247 | + * @throws InvalidArgumentException |
|
| 248 | + * @throws InvalidDataTypeException |
|
| 249 | + * @throws InvalidInterfaceException |
|
| 250 | + */ |
|
| 251 | + public function isAdmin() |
|
| 252 | + { |
|
| 253 | + return $this->request()->isAdmin(); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + /** |
|
| 258 | + * @deprecated 4.9.53 |
|
| 259 | + * @return mixed |
|
| 260 | + * @throws InvalidArgumentException |
|
| 261 | + * @throws InvalidDataTypeException |
|
| 262 | + * @throws InvalidInterfaceException |
|
| 263 | + */ |
|
| 264 | + public function isAjax() |
|
| 265 | + { |
|
| 266 | + return $this->request()->isAjax(); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @deprecated 4.9.53 |
|
| 272 | + * @return mixed |
|
| 273 | + * @throws InvalidArgumentException |
|
| 274 | + * @throws InvalidDataTypeException |
|
| 275 | + * @throws InvalidInterfaceException |
|
| 276 | + */ |
|
| 277 | + public function isFrontAjax() |
|
| 278 | + { |
|
| 279 | + return $this->request()->isFrontAjax(); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * @deprecated 4.9.53 |
|
| 285 | + * @return mixed|string |
|
| 286 | + * @throws InvalidArgumentException |
|
| 287 | + * @throws InvalidDataTypeException |
|
| 288 | + * @throws InvalidInterfaceException |
|
| 289 | + */ |
|
| 290 | + public function requestUri() |
|
| 291 | + { |
|
| 292 | + return $this->request()->requestUri(); |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @deprecated 4.9.53 |
|
| 298 | + * @return string |
|
| 299 | + * @throws InvalidArgumentException |
|
| 300 | + * @throws InvalidDataTypeException |
|
| 301 | + * @throws InvalidInterfaceException |
|
| 302 | + */ |
|
| 303 | + public function userAgent() |
|
| 304 | + { |
|
| 305 | + return $this->request()->userAgent(); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * @deprecated 4.9.53 |
|
| 311 | + * @param string $user_agent |
|
| 312 | + * @throws InvalidArgumentException |
|
| 313 | + * @throws InvalidDataTypeException |
|
| 314 | + * @throws InvalidInterfaceException |
|
| 315 | + */ |
|
| 316 | + public function setUserAgent($user_agent = '') |
|
| 317 | + { |
|
| 318 | + $this->request()->setUserAgent($user_agent); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * @deprecated 4.9.53 |
|
| 324 | + * @return bool |
|
| 325 | + * @throws InvalidArgumentException |
|
| 326 | + * @throws InvalidDataTypeException |
|
| 327 | + * @throws InvalidInterfaceException |
|
| 328 | + */ |
|
| 329 | + public function isBot() |
|
| 330 | + { |
|
| 331 | + return $this->request()->isBot(); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * @deprecated 4.9.53 |
|
| 337 | + * @param bool $is_bot |
|
| 338 | + * @throws InvalidArgumentException |
|
| 339 | + * @throws InvalidDataTypeException |
|
| 340 | + * @throws InvalidInterfaceException |
|
| 341 | + */ |
|
| 342 | + public function setIsBot($is_bot) |
|
| 343 | + { |
|
| 344 | + $this->request()->setIsBot($is_bot); |
|
| 345 | + } |
|
| 346 | 346 | |
| 347 | 347 | |
| 348 | 348 | |
@@ -69,7 +69,7 @@ |
||
| 69 | 69 | */ |
| 70 | 70 | private function request() |
| 71 | 71 | { |
| 72 | - if($this->request instanceof RequestInterface){ |
|
| 72 | + if ($this->request instanceof RequestInterface) { |
|
| 73 | 73 | return $this->request; |
| 74 | 74 | } |
| 75 | 75 | $loader = LoaderFactory::getLoader(); |
@@ -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 |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | /** |
| 50 | 50 | * @deprecated 4.9.53 |
| 51 | 51 | */ |
| 52 | - public function resolve( EEI_Request_Decorator $application ) { |
|
| 52 | + public function resolve(EEI_Request_Decorator $application) { |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | |
@@ -15,45 +15,45 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class EE_Request_Stack_Builder { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * EE_Request_Stack_Builder |
|
| 20 | - */ |
|
| 21 | - public function __construct() |
|
| 22 | - { |
|
| 23 | - EE_Error::doing_it_wrong( |
|
| 24 | - __METHOD__, |
|
| 25 | - sprintf( |
|
| 26 | - esc_html__( |
|
| 27 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 28 | - 'event_espresso' |
|
| 29 | - ), |
|
| 30 | - 'EventEspresso\core\services\request\RequestStackBuilder', |
|
| 31 | - '\core\services\request', |
|
| 32 | - 'EventEspresso\core\services\request' |
|
| 33 | - ), |
|
| 34 | - '4.9.53' |
|
| 35 | - ); |
|
| 36 | - } |
|
| 18 | + /** |
|
| 19 | + * EE_Request_Stack_Builder |
|
| 20 | + */ |
|
| 21 | + public function __construct() |
|
| 22 | + { |
|
| 23 | + EE_Error::doing_it_wrong( |
|
| 24 | + __METHOD__, |
|
| 25 | + sprintf( |
|
| 26 | + esc_html__( |
|
| 27 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 28 | + 'event_espresso' |
|
| 29 | + ), |
|
| 30 | + 'EventEspresso\core\services\request\RequestStackBuilder', |
|
| 31 | + '\core\services\request', |
|
| 32 | + 'EventEspresso\core\services\request' |
|
| 33 | + ), |
|
| 34 | + '4.9.53' |
|
| 35 | + ); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @deprecated 4.9.53 |
|
| 40 | - */ |
|
| 38 | + /** |
|
| 39 | + * @deprecated 4.9.53 |
|
| 40 | + */ |
|
| 41 | 41 | public function unshift( /*$class_name, $args*/ ) { |
| 42 | - } |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @deprecated 4.9.53 |
|
| 48 | - */ |
|
| 46 | + /** |
|
| 47 | + * @deprecated 4.9.53 |
|
| 48 | + */ |
|
| 49 | 49 | public function push( /*$class_name, $args...*/ ) { |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @deprecated 4.9.53 |
|
| 56 | - */ |
|
| 54 | + /** |
|
| 55 | + * @deprecated 4.9.53 |
|
| 56 | + */ |
|
| 57 | 57 | public function resolve( EEI_Request_Decorator $application ) { |
| 58 | 58 | } |
| 59 | 59 | |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | 2 | exit('No direct script access allowed'); |
| 3 | 3 | } |
| 4 | 4 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function set_notice($key, $value) |
| 74 | 74 | { |
| 75 | - $this->_notice[ $key ] = $value; |
|
| 75 | + $this->_notice[$key] = $value; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | public function get_notice($key) |
| 86 | 86 | { |
| 87 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 87 | + return isset($this->_notice[$key]) ? $this->_notice[$key] : null; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function add_output($string, $append = true) |
| 109 | 109 | { |
| 110 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 110 | + $this->_output = $append ? $this->_output.$string : $string.$this->_output; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php if (! defined('EVENT_ESPRESSO_VERSION')) { |
| 2 | - exit('No direct script access allowed'); |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | |
| 5 | 5 | |
@@ -17,158 +17,158 @@ discard block |
||
| 17 | 17 | class EE_Response |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @access protected |
|
| 22 | - * @type array $_notice |
|
| 23 | - */ |
|
| 24 | - protected $_notice = array(); |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * rendered output to be returned to WP |
|
| 28 | - * |
|
| 29 | - * @access protected |
|
| 30 | - * @type string |
|
| 31 | - */ |
|
| 32 | - protected $_output = ''; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @access protected |
|
| 36 | - * @type bool |
|
| 37 | - */ |
|
| 38 | - protected $request_terminated = false; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @access protected |
|
| 42 | - * @type bool |
|
| 43 | - */ |
|
| 44 | - protected $deactivate_plugin = false; |
|
| 45 | - |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @deprecated 4.9.53 |
|
| 50 | - * @return \EE_Response |
|
| 51 | - */ |
|
| 52 | - public function __construct() |
|
| 53 | - { |
|
| 54 | - $this->terminate_request(false); |
|
| 55 | - EE_Error::doing_it_wrong( |
|
| 56 | - __METHOD__, |
|
| 57 | - sprintf( |
|
| 58 | - esc_html__( |
|
| 59 | - 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 60 | - 'event_espresso' |
|
| 61 | - ), |
|
| 62 | - 'EventEspresso\core\services\request\Response', |
|
| 63 | - '\core\services\request', |
|
| 64 | - 'EventEspresso\core\services\request' |
|
| 65 | - ), |
|
| 66 | - '4.9.53' |
|
| 67 | - ); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @deprecated 4.9.53 |
|
| 74 | - * @param $key |
|
| 75 | - * @param $value |
|
| 76 | - * @return void |
|
| 77 | - */ |
|
| 78 | - public function set_notice($key, $value) |
|
| 79 | - { |
|
| 80 | - $this->_notice[ $key ] = $value; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - /** |
|
| 86 | - * @deprecated 4.9.53 |
|
| 87 | - * @param $key |
|
| 88 | - * @return mixed |
|
| 89 | - */ |
|
| 90 | - public function get_notice($key) |
|
| 91 | - { |
|
| 92 | - return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @deprecated 4.9.53 |
|
| 99 | - * @return array |
|
| 100 | - */ |
|
| 101 | - public function get_notices() |
|
| 102 | - { |
|
| 103 | - return $this->_notice; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @deprecated 4.9.53 |
|
| 110 | - * @param $string |
|
| 111 | - * @param bool $append |
|
| 112 | - */ |
|
| 113 | - public function add_output($string, $append = true) |
|
| 114 | - { |
|
| 115 | - $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @deprecated 4.9.53 |
|
| 122 | - * @return string |
|
| 123 | - */ |
|
| 124 | - public function get_output() |
|
| 125 | - { |
|
| 126 | - return $this->_output; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @deprecated 4.9.53 |
|
| 133 | - * @return boolean |
|
| 134 | - */ |
|
| 135 | - public function request_terminated() |
|
| 136 | - { |
|
| 137 | - return $this->request_terminated; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @deprecated 4.9.53 |
|
| 144 | - * @param boolean $request_terminated |
|
| 145 | - */ |
|
| 146 | - public function terminate_request($request_terminated = true) |
|
| 147 | - { |
|
| 148 | - $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @deprecated 4.9.53 |
|
| 155 | - * @return boolean |
|
| 156 | - */ |
|
| 157 | - public function plugin_deactivated() |
|
| 158 | - { |
|
| 159 | - return $this->deactivate_plugin; |
|
| 160 | - } |
|
| 20 | + /** |
|
| 21 | + * @access protected |
|
| 22 | + * @type array $_notice |
|
| 23 | + */ |
|
| 24 | + protected $_notice = array(); |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * rendered output to be returned to WP |
|
| 28 | + * |
|
| 29 | + * @access protected |
|
| 30 | + * @type string |
|
| 31 | + */ |
|
| 32 | + protected $_output = ''; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @access protected |
|
| 36 | + * @type bool |
|
| 37 | + */ |
|
| 38 | + protected $request_terminated = false; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @access protected |
|
| 42 | + * @type bool |
|
| 43 | + */ |
|
| 44 | + protected $deactivate_plugin = false; |
|
| 45 | + |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @deprecated 4.9.53 |
|
| 50 | + * @return \EE_Response |
|
| 51 | + */ |
|
| 52 | + public function __construct() |
|
| 53 | + { |
|
| 54 | + $this->terminate_request(false); |
|
| 55 | + EE_Error::doing_it_wrong( |
|
| 56 | + __METHOD__, |
|
| 57 | + sprintf( |
|
| 58 | + esc_html__( |
|
| 59 | + 'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace', |
|
| 60 | + 'event_espresso' |
|
| 61 | + ), |
|
| 62 | + 'EventEspresso\core\services\request\Response', |
|
| 63 | + '\core\services\request', |
|
| 64 | + 'EventEspresso\core\services\request' |
|
| 65 | + ), |
|
| 66 | + '4.9.53' |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @deprecated 4.9.53 |
|
| 74 | + * @param $key |
|
| 75 | + * @param $value |
|
| 76 | + * @return void |
|
| 77 | + */ |
|
| 78 | + public function set_notice($key, $value) |
|
| 79 | + { |
|
| 80 | + $this->_notice[ $key ] = $value; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + /** |
|
| 86 | + * @deprecated 4.9.53 |
|
| 87 | + * @param $key |
|
| 88 | + * @return mixed |
|
| 89 | + */ |
|
| 90 | + public function get_notice($key) |
|
| 91 | + { |
|
| 92 | + return isset($this->_notice[ $key ]) ? $this->_notice[ $key ] : null; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @deprecated 4.9.53 |
|
| 99 | + * @return array |
|
| 100 | + */ |
|
| 101 | + public function get_notices() |
|
| 102 | + { |
|
| 103 | + return $this->_notice; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @deprecated 4.9.53 |
|
| 110 | + * @param $string |
|
| 111 | + * @param bool $append |
|
| 112 | + */ |
|
| 113 | + public function add_output($string, $append = true) |
|
| 114 | + { |
|
| 115 | + $this->_output = $append ? $this->_output . $string : $string . $this->_output; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @deprecated 4.9.53 |
|
| 122 | + * @return string |
|
| 123 | + */ |
|
| 124 | + public function get_output() |
|
| 125 | + { |
|
| 126 | + return $this->_output; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @deprecated 4.9.53 |
|
| 133 | + * @return boolean |
|
| 134 | + */ |
|
| 135 | + public function request_terminated() |
|
| 136 | + { |
|
| 137 | + return $this->request_terminated; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @deprecated 4.9.53 |
|
| 144 | + * @param boolean $request_terminated |
|
| 145 | + */ |
|
| 146 | + public function terminate_request($request_terminated = true) |
|
| 147 | + { |
|
| 148 | + $this->request_terminated = filter_var($request_terminated, FILTER_VALIDATE_BOOLEAN); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @deprecated 4.9.53 |
|
| 155 | + * @return boolean |
|
| 156 | + */ |
|
| 157 | + public function plugin_deactivated() |
|
| 158 | + { |
|
| 159 | + return $this->deactivate_plugin; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * @deprecated 4.9.53 |
|
| 166 | - * sets $deactivate_plugin to true |
|
| 167 | - */ |
|
| 168 | - public function deactivate_plugin() |
|
| 169 | - { |
|
| 170 | - $this->deactivate_plugin = true; |
|
| 171 | - } |
|
| 164 | + /** |
|
| 165 | + * @deprecated 4.9.53 |
|
| 166 | + * sets $deactivate_plugin to true |
|
| 167 | + */ |
|
| 168 | + public function deactivate_plugin() |
|
| 169 | + { |
|
| 170 | + $this->deactivate_plugin = true; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | 174 | } |
@@ -97,7 +97,7 @@ |
||
| 97 | 97 | $ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0') |
| 98 | 98 | ? trim(rest_get_url_prefix(), '/') |
| 99 | 99 | : 'wp-json'; |
| 100 | - $ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE; |
|
| 100 | + $ee_rest_url_prefix .= '/'.Domain::API_NAMESPACE; |
|
| 101 | 101 | return $this->uriPathMatches($ee_rest_url_prefix); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -23,133 +23,133 @@ |
||
| 23 | 23 | class RequestTypeContextDetector |
| 24 | 24 | { |
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var RequestTypeContextFactory $factory |
|
| 28 | - */ |
|
| 29 | - private $factory; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var RequestInterface $request |
|
| 33 | - */ |
|
| 34 | - private $request; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * RequestTypeContextDetector constructor. |
|
| 39 | - * |
|
| 40 | - * @param RequestInterface $request |
|
| 41 | - * @param RequestTypeContextFactory $factory |
|
| 42 | - */ |
|
| 43 | - public function __construct(RequestInterface $request, RequestTypeContextFactory $factory) |
|
| 44 | - { |
|
| 45 | - $this->request = $request; |
|
| 46 | - $this->factory = $factory; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @return RequestTypeContext |
|
| 52 | - * @throws InvalidArgumentException |
|
| 53 | - */ |
|
| 54 | - public function detectRequestTypeContext() |
|
| 55 | - { |
|
| 56 | - // Detect EE REST API |
|
| 57 | - if ($this->isEspressoRestApiRequest()) { |
|
| 58 | - return $this->factory->create(RequestTypeContext::API); |
|
| 59 | - } |
|
| 60 | - // Detect AJAX |
|
| 61 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 62 | - if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 63 | - return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
| 64 | - } |
|
| 65 | - if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 66 | - return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
| 67 | - } |
|
| 68 | - return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
| 69 | - } |
|
| 70 | - // Detect WP_Cron |
|
| 71 | - if ($this->isCronRequest()) { |
|
| 72 | - return $this->factory->create(RequestTypeContext::CRON); |
|
| 73 | - } |
|
| 74 | - // Detect command line requests |
|
| 75 | - if (defined('WP_CLI') && WP_CLI) { |
|
| 76 | - return $this->factory->create(RequestTypeContext::CLI); |
|
| 77 | - } |
|
| 78 | - // detect WordPress admin (ie: "Dashboard") |
|
| 79 | - if (is_admin()) { |
|
| 80 | - return $this->factory->create(RequestTypeContext::ADMIN); |
|
| 81 | - } |
|
| 82 | - // Detect iFrames |
|
| 83 | - if ($this->isIframeRoute()) { |
|
| 84 | - return $this->factory->create(RequestTypeContext::IFRAME); |
|
| 85 | - } |
|
| 86 | - // Detect Feeds |
|
| 87 | - if ($this->isFeedRequest()) { |
|
| 88 | - return $this->factory->create(RequestTypeContext::FEED); |
|
| 89 | - } |
|
| 90 | - // and by process of elimination... |
|
| 91 | - return $this->factory->create(RequestTypeContext::FRONTEND); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * @return bool |
|
| 97 | - */ |
|
| 98 | - private function isEspressoRestApiRequest() |
|
| 99 | - { |
|
| 100 | - $ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0') |
|
| 101 | - ? trim(rest_get_url_prefix(), '/') |
|
| 102 | - : 'wp-json'; |
|
| 103 | - $ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE; |
|
| 104 | - return $this->uriPathMatches($ee_rest_url_prefix); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @return bool |
|
| 110 | - */ |
|
| 111 | - private function isCronRequest() |
|
| 112 | - { |
|
| 113 | - return $this->uriPathMatches('wp-cron.php'); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @return bool |
|
| 119 | - */ |
|
| 120 | - private function isFeedRequest() |
|
| 121 | - { |
|
| 122 | - return $this->uriPathMatches('feed'); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * @param string $component |
|
| 128 | - * @return bool |
|
| 129 | - */ |
|
| 130 | - private function uriPathMatches($component) |
|
| 131 | - { |
|
| 132 | - $request_uri = $this->request->requestUri(); |
|
| 133 | - $parts = explode('?', $request_uri); |
|
| 134 | - $path = trim(reset($parts), '/'); |
|
| 135 | - return strpos($path, $component) === 0; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * @return bool |
|
| 141 | - */ |
|
| 142 | - private function isIframeRoute() |
|
| 143 | - { |
|
| 144 | - $is_iframe_route = apply_filters( |
|
| 145 | - 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
| 146 | - $this->request->getRequestParam('event_list', '') === 'iframe' |
|
| 147 | - || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
| 148 | - || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
| 149 | - $this |
|
| 150 | - ); |
|
| 151 | - return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
| 152 | - } |
|
| 26 | + /** |
|
| 27 | + * @var RequestTypeContextFactory $factory |
|
| 28 | + */ |
|
| 29 | + private $factory; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var RequestInterface $request |
|
| 33 | + */ |
|
| 34 | + private $request; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * RequestTypeContextDetector constructor. |
|
| 39 | + * |
|
| 40 | + * @param RequestInterface $request |
|
| 41 | + * @param RequestTypeContextFactory $factory |
|
| 42 | + */ |
|
| 43 | + public function __construct(RequestInterface $request, RequestTypeContextFactory $factory) |
|
| 44 | + { |
|
| 45 | + $this->request = $request; |
|
| 46 | + $this->factory = $factory; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @return RequestTypeContext |
|
| 52 | + * @throws InvalidArgumentException |
|
| 53 | + */ |
|
| 54 | + public function detectRequestTypeContext() |
|
| 55 | + { |
|
| 56 | + // Detect EE REST API |
|
| 57 | + if ($this->isEspressoRestApiRequest()) { |
|
| 58 | + return $this->factory->create(RequestTypeContext::API); |
|
| 59 | + } |
|
| 60 | + // Detect AJAX |
|
| 61 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
| 62 | + if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 63 | + return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
| 64 | + } |
|
| 65 | + if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 66 | + return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
| 67 | + } |
|
| 68 | + return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
| 69 | + } |
|
| 70 | + // Detect WP_Cron |
|
| 71 | + if ($this->isCronRequest()) { |
|
| 72 | + return $this->factory->create(RequestTypeContext::CRON); |
|
| 73 | + } |
|
| 74 | + // Detect command line requests |
|
| 75 | + if (defined('WP_CLI') && WP_CLI) { |
|
| 76 | + return $this->factory->create(RequestTypeContext::CLI); |
|
| 77 | + } |
|
| 78 | + // detect WordPress admin (ie: "Dashboard") |
|
| 79 | + if (is_admin()) { |
|
| 80 | + return $this->factory->create(RequestTypeContext::ADMIN); |
|
| 81 | + } |
|
| 82 | + // Detect iFrames |
|
| 83 | + if ($this->isIframeRoute()) { |
|
| 84 | + return $this->factory->create(RequestTypeContext::IFRAME); |
|
| 85 | + } |
|
| 86 | + // Detect Feeds |
|
| 87 | + if ($this->isFeedRequest()) { |
|
| 88 | + return $this->factory->create(RequestTypeContext::FEED); |
|
| 89 | + } |
|
| 90 | + // and by process of elimination... |
|
| 91 | + return $this->factory->create(RequestTypeContext::FRONTEND); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * @return bool |
|
| 97 | + */ |
|
| 98 | + private function isEspressoRestApiRequest() |
|
| 99 | + { |
|
| 100 | + $ee_rest_url_prefix = RecommendedVersions::compareWordPressVersion('4.4.0') |
|
| 101 | + ? trim(rest_get_url_prefix(), '/') |
|
| 102 | + : 'wp-json'; |
|
| 103 | + $ee_rest_url_prefix .= '/' . Domain::API_NAMESPACE; |
|
| 104 | + return $this->uriPathMatches($ee_rest_url_prefix); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @return bool |
|
| 110 | + */ |
|
| 111 | + private function isCronRequest() |
|
| 112 | + { |
|
| 113 | + return $this->uriPathMatches('wp-cron.php'); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @return bool |
|
| 119 | + */ |
|
| 120 | + private function isFeedRequest() |
|
| 121 | + { |
|
| 122 | + return $this->uriPathMatches('feed'); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * @param string $component |
|
| 128 | + * @return bool |
|
| 129 | + */ |
|
| 130 | + private function uriPathMatches($component) |
|
| 131 | + { |
|
| 132 | + $request_uri = $this->request->requestUri(); |
|
| 133 | + $parts = explode('?', $request_uri); |
|
| 134 | + $path = trim(reset($parts), '/'); |
|
| 135 | + return strpos($path, $component) === 0; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * @return bool |
|
| 141 | + */ |
|
| 142 | + private function isIframeRoute() |
|
| 143 | + { |
|
| 144 | + $is_iframe_route = apply_filters( |
|
| 145 | + 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
| 146 | + $this->request->getRequestParam('event_list', '') === 'iframe' |
|
| 147 | + || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
| 148 | + || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
| 149 | + $this |
|
| 150 | + ); |
|
| 151 | + return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | 154 | } |
| 155 | 155 | // Location: RequestTypeContextDetector.php |