@@ -20,192 +20,192 @@ |
||
20 | 20 | class OpenCoffeeShop |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var CoffeeShop $CoffeeShop |
|
25 | - */ |
|
26 | - private $CoffeeShop; |
|
23 | + /** |
|
24 | + * @var CoffeeShop $CoffeeShop |
|
25 | + */ |
|
26 | + private $CoffeeShop; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * OpenCoffeeShop constructor |
|
31 | - * |
|
32 | - * @throws InvalidInterfaceException |
|
33 | - */ |
|
34 | - public function __construct() |
|
35 | - { |
|
36 | - // instantiate the DI container |
|
37 | - $this->CoffeeShop = new CoffeeShop(); |
|
38 | - } |
|
29 | + /** |
|
30 | + * OpenCoffeeShop constructor |
|
31 | + * |
|
32 | + * @throws InvalidInterfaceException |
|
33 | + */ |
|
34 | + public function __construct() |
|
35 | + { |
|
36 | + // instantiate the DI container |
|
37 | + $this->CoffeeShop = new CoffeeShop(); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | - /** |
|
43 | - * @return CoffeeShop |
|
44 | - */ |
|
45 | - public function CoffeeShop() |
|
46 | - { |
|
47 | - return $this->CoffeeShop; |
|
48 | - } |
|
41 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
42 | + /** |
|
43 | + * @return CoffeeShop |
|
44 | + */ |
|
45 | + public function CoffeeShop() |
|
46 | + { |
|
47 | + return $this->CoffeeShop; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * configure coffee makers which control the different kinds of brews |
|
53 | - * ( shared services, new factory objects, etc ) |
|
54 | - * |
|
55 | - * @throws InvalidEntityException |
|
56 | - */ |
|
57 | - public function setupCoffeeMakers() |
|
58 | - { |
|
59 | - // create a dependency injector class for resolving class constructor arguments |
|
60 | - $DependencyInjector = new DependencyInjector( |
|
61 | - $this->CoffeeShop, |
|
62 | - new \EEH_Array() |
|
63 | - ); |
|
64 | - // and some coffeemakers, one for creating new instances |
|
65 | - $this->CoffeeShop->addCoffeeMaker( |
|
66 | - new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
67 | - CoffeeMaker::BREW_NEW |
|
68 | - ); |
|
69 | - // one for shared services |
|
70 | - $this->CoffeeShop->addCoffeeMaker( |
|
71 | - new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
72 | - CoffeeMaker::BREW_SHARED |
|
73 | - ); |
|
74 | - // and one for classes that only get loaded |
|
75 | - $this->CoffeeShop->addCoffeeMaker( |
|
76 | - new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
77 | - CoffeeMaker::BREW_LOAD_ONLY |
|
78 | - ); |
|
79 | - } |
|
51 | + /** |
|
52 | + * configure coffee makers which control the different kinds of brews |
|
53 | + * ( shared services, new factory objects, etc ) |
|
54 | + * |
|
55 | + * @throws InvalidEntityException |
|
56 | + */ |
|
57 | + public function setupCoffeeMakers() |
|
58 | + { |
|
59 | + // create a dependency injector class for resolving class constructor arguments |
|
60 | + $DependencyInjector = new DependencyInjector( |
|
61 | + $this->CoffeeShop, |
|
62 | + new \EEH_Array() |
|
63 | + ); |
|
64 | + // and some coffeemakers, one for creating new instances |
|
65 | + $this->CoffeeShop->addCoffeeMaker( |
|
66 | + new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
67 | + CoffeeMaker::BREW_NEW |
|
68 | + ); |
|
69 | + // one for shared services |
|
70 | + $this->CoffeeShop->addCoffeeMaker( |
|
71 | + new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
72 | + CoffeeMaker::BREW_SHARED |
|
73 | + ); |
|
74 | + // and one for classes that only get loaded |
|
75 | + $this->CoffeeShop->addCoffeeMaker( |
|
76 | + new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
77 | + CoffeeMaker::BREW_LOAD_ONLY |
|
78 | + ); |
|
79 | + } |
|
80 | 80 | |
81 | 81 | |
82 | - /** |
|
83 | - * Recipes define how to load legacy classes |
|
84 | - * |
|
85 | - * @throws InvalidIdentifierException |
|
86 | - */ |
|
87 | - public function addRecipes() |
|
88 | - { |
|
89 | - // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
90 | - // as long as they are not type hinting for interfaces |
|
91 | - $this->CoffeeShop->addRecipe( |
|
92 | - new Recipe( |
|
93 | - Recipe::DEFAULT_ID |
|
94 | - ) |
|
95 | - ); |
|
96 | - // PSR-4 compatible class with aliases |
|
97 | - $this->CoffeeShop->addRecipe( |
|
98 | - new Recipe( |
|
99 | - 'CommandHandlerManager', |
|
100 | - 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
101 | - array( |
|
102 | - 'CommandHandlerManagerInterface', |
|
103 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
104 | - ), |
|
105 | - array(), |
|
106 | - CoffeeMaker::BREW_SHARED |
|
107 | - ) |
|
108 | - ); |
|
109 | - // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
110 | - $this->CoffeeShop->addRecipe( |
|
111 | - new Recipe( |
|
112 | - 'CommandBus', |
|
113 | - 'EventEspresso\core\services\commands\CommandBus', |
|
114 | - array( |
|
115 | - 'CommandBusInterface', |
|
116 | - 'EventEspresso\core\services\commands\CommandBusInterface', |
|
117 | - ), |
|
118 | - array(), |
|
119 | - CoffeeMaker::BREW_SHARED |
|
120 | - ) |
|
121 | - ); |
|
122 | - // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
123 | - // add a wildcard recipe for loading legacy core interfaces |
|
124 | - $this->CoffeeShop->addRecipe( |
|
125 | - new Recipe( |
|
126 | - 'EEI_*', |
|
127 | - '', |
|
128 | - array(), |
|
129 | - array(), |
|
130 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
131 | - array( |
|
132 | - EE_INTERFACES . '*.php', |
|
133 | - EE_INTERFACES . '*.interfaces.php', |
|
134 | - ) |
|
135 | - ) |
|
136 | - ); |
|
137 | - // add a wildcard recipe for loading models |
|
138 | - $this->CoffeeShop->addRecipe( |
|
139 | - new Recipe( |
|
140 | - 'EEM_*', |
|
141 | - '', |
|
142 | - array(), |
|
143 | - array(), |
|
144 | - CoffeeMaker::BREW_SHARED, |
|
145 | - EE_MODELS . '*.model.php' |
|
146 | - ) |
|
147 | - ); |
|
148 | - // add a wildcard recipe for loading core classes |
|
149 | - $this->CoffeeShop->addRecipe( |
|
150 | - new Recipe( |
|
151 | - 'EE_*', |
|
152 | - '', |
|
153 | - array(), |
|
154 | - array(), |
|
155 | - CoffeeMaker::BREW_SHARED, |
|
156 | - array( |
|
157 | - EE_CORE . '*.core.php', |
|
158 | - EE_ADMIN . '*.core.php', |
|
159 | - EE_CPTS . '*.core.php', |
|
160 | - EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
|
161 | - ) |
|
162 | - ) |
|
163 | - ); |
|
164 | - // load admin page parent class |
|
165 | - $this->CoffeeShop->addRecipe( |
|
166 | - new Recipe( |
|
167 | - 'EE_Admin_Page*', |
|
168 | - '', |
|
169 | - array(), |
|
170 | - array(), |
|
171 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
172 | - array(EE_ADMIN . '*.core.php') |
|
173 | - ) |
|
174 | - ); |
|
175 | - // add a wildcard recipe for loading core classes |
|
176 | - // $this->CoffeeShop->addRecipe( |
|
177 | - // new Recipe( |
|
178 | - // '*_Admin_Page', |
|
179 | - // '', |
|
180 | - // array(), |
|
181 | - // array(), |
|
182 | - // CoffeeMaker::BREW_SHARED, |
|
183 | - // array( |
|
184 | - // EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php', |
|
185 | - // ) |
|
186 | - // ) |
|
187 | - // ); |
|
188 | - } |
|
82 | + /** |
|
83 | + * Recipes define how to load legacy classes |
|
84 | + * |
|
85 | + * @throws InvalidIdentifierException |
|
86 | + */ |
|
87 | + public function addRecipes() |
|
88 | + { |
|
89 | + // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
90 | + // as long as they are not type hinting for interfaces |
|
91 | + $this->CoffeeShop->addRecipe( |
|
92 | + new Recipe( |
|
93 | + Recipe::DEFAULT_ID |
|
94 | + ) |
|
95 | + ); |
|
96 | + // PSR-4 compatible class with aliases |
|
97 | + $this->CoffeeShop->addRecipe( |
|
98 | + new Recipe( |
|
99 | + 'CommandHandlerManager', |
|
100 | + 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
101 | + array( |
|
102 | + 'CommandHandlerManagerInterface', |
|
103 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
104 | + ), |
|
105 | + array(), |
|
106 | + CoffeeMaker::BREW_SHARED |
|
107 | + ) |
|
108 | + ); |
|
109 | + // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
110 | + $this->CoffeeShop->addRecipe( |
|
111 | + new Recipe( |
|
112 | + 'CommandBus', |
|
113 | + 'EventEspresso\core\services\commands\CommandBus', |
|
114 | + array( |
|
115 | + 'CommandBusInterface', |
|
116 | + 'EventEspresso\core\services\commands\CommandBusInterface', |
|
117 | + ), |
|
118 | + array(), |
|
119 | + CoffeeMaker::BREW_SHARED |
|
120 | + ) |
|
121 | + ); |
|
122 | + // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
123 | + // add a wildcard recipe for loading legacy core interfaces |
|
124 | + $this->CoffeeShop->addRecipe( |
|
125 | + new Recipe( |
|
126 | + 'EEI_*', |
|
127 | + '', |
|
128 | + array(), |
|
129 | + array(), |
|
130 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
131 | + array( |
|
132 | + EE_INTERFACES . '*.php', |
|
133 | + EE_INTERFACES . '*.interfaces.php', |
|
134 | + ) |
|
135 | + ) |
|
136 | + ); |
|
137 | + // add a wildcard recipe for loading models |
|
138 | + $this->CoffeeShop->addRecipe( |
|
139 | + new Recipe( |
|
140 | + 'EEM_*', |
|
141 | + '', |
|
142 | + array(), |
|
143 | + array(), |
|
144 | + CoffeeMaker::BREW_SHARED, |
|
145 | + EE_MODELS . '*.model.php' |
|
146 | + ) |
|
147 | + ); |
|
148 | + // add a wildcard recipe for loading core classes |
|
149 | + $this->CoffeeShop->addRecipe( |
|
150 | + new Recipe( |
|
151 | + 'EE_*', |
|
152 | + '', |
|
153 | + array(), |
|
154 | + array(), |
|
155 | + CoffeeMaker::BREW_SHARED, |
|
156 | + array( |
|
157 | + EE_CORE . '*.core.php', |
|
158 | + EE_ADMIN . '*.core.php', |
|
159 | + EE_CPTS . '*.core.php', |
|
160 | + EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
|
161 | + ) |
|
162 | + ) |
|
163 | + ); |
|
164 | + // load admin page parent class |
|
165 | + $this->CoffeeShop->addRecipe( |
|
166 | + new Recipe( |
|
167 | + 'EE_Admin_Page*', |
|
168 | + '', |
|
169 | + array(), |
|
170 | + array(), |
|
171 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
172 | + array(EE_ADMIN . '*.core.php') |
|
173 | + ) |
|
174 | + ); |
|
175 | + // add a wildcard recipe for loading core classes |
|
176 | + // $this->CoffeeShop->addRecipe( |
|
177 | + // new Recipe( |
|
178 | + // '*_Admin_Page', |
|
179 | + // '', |
|
180 | + // array(), |
|
181 | + // array(), |
|
182 | + // CoffeeMaker::BREW_SHARED, |
|
183 | + // array( |
|
184 | + // EE_ADMIN_PAGES . 'transactions' . DS . '*.core.php', |
|
185 | + // ) |
|
186 | + // ) |
|
187 | + // ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * bootstrap EE and the request stack |
|
193 | - * |
|
194 | - * @throws ServiceNotFoundException |
|
195 | - * @throws InvalidClassException |
|
196 | - * @throws InvalidDataTypeException |
|
197 | - * @throws InvalidIdentifierException |
|
198 | - * @throws exceptions\ServiceExistsException |
|
199 | - * @throws OutOfBoundsException |
|
200 | - * @throws exceptions\InstantiationException |
|
201 | - */ |
|
202 | - public function firstBrew() |
|
203 | - { |
|
204 | - $this->CoffeeShop->brew( |
|
205 | - 'EventEspresso\core\services\request\Request', |
|
206 | - array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
207 | - ); |
|
208 | - $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
209 | - $this->CoffeeShop->brew('EE_Bootstrap'); |
|
210 | - } |
|
191 | + /** |
|
192 | + * bootstrap EE and the request stack |
|
193 | + * |
|
194 | + * @throws ServiceNotFoundException |
|
195 | + * @throws InvalidClassException |
|
196 | + * @throws InvalidDataTypeException |
|
197 | + * @throws InvalidIdentifierException |
|
198 | + * @throws exceptions\ServiceExistsException |
|
199 | + * @throws OutOfBoundsException |
|
200 | + * @throws exceptions\InstantiationException |
|
201 | + */ |
|
202 | + public function firstBrew() |
|
203 | + { |
|
204 | + $this->CoffeeShop->brew( |
|
205 | + 'EventEspresso\core\services\request\Request', |
|
206 | + array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
207 | + ); |
|
208 | + $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
209 | + $this->CoffeeShop->brew('EE_Bootstrap'); |
|
210 | + } |
|
211 | 211 | } |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | array(), |
130 | 130 | CoffeeMaker::BREW_LOAD_ONLY, |
131 | 131 | array( |
132 | - EE_INTERFACES . '*.php', |
|
133 | - EE_INTERFACES . '*.interfaces.php', |
|
132 | + EE_INTERFACES.'*.php', |
|
133 | + EE_INTERFACES.'*.interfaces.php', |
|
134 | 134 | ) |
135 | 135 | ) |
136 | 136 | ); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | array(), |
143 | 143 | array(), |
144 | 144 | CoffeeMaker::BREW_SHARED, |
145 | - EE_MODELS . '*.model.php' |
|
145 | + EE_MODELS.'*.model.php' |
|
146 | 146 | ) |
147 | 147 | ); |
148 | 148 | // add a wildcard recipe for loading core classes |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | array(), |
155 | 155 | CoffeeMaker::BREW_SHARED, |
156 | 156 | array( |
157 | - EE_CORE . '*.core.php', |
|
158 | - EE_ADMIN . '*.core.php', |
|
159 | - EE_CPTS . '*.core.php', |
|
160 | - EE_CORE . 'data_migration_scripts' . DS . '*.core.php', |
|
157 | + EE_CORE.'*.core.php', |
|
158 | + EE_ADMIN.'*.core.php', |
|
159 | + EE_CPTS.'*.core.php', |
|
160 | + EE_CORE.'data_migration_scripts'.DS.'*.core.php', |
|
161 | 161 | ) |
162 | 162 | ) |
163 | 163 | ); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | array(), |
170 | 170 | array(), |
171 | 171 | CoffeeMaker::BREW_LOAD_ONLY, |
172 | - array(EE_ADMIN . '*.core.php') |
|
172 | + array(EE_ADMIN.'*.core.php') |
|
173 | 173 | ) |
174 | 174 | ); |
175 | 175 | // add a wildcard recipe for loading core classes |
@@ -15,59 +15,59 @@ |
||
15 | 15 | class CoffeeMill |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var CoffeeShop $coffee_shop |
|
20 | - */ |
|
21 | - private static $coffee_shop; |
|
18 | + /** |
|
19 | + * @var CoffeeShop $coffee_shop |
|
20 | + */ |
|
21 | + private static $coffee_shop; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * @return mixed |
|
26 | - */ |
|
27 | - public static function getCoffeeShop() |
|
28 | - { |
|
29 | - return self::$coffee_shop; |
|
30 | - } |
|
24 | + /** |
|
25 | + * @return mixed |
|
26 | + */ |
|
27 | + public static function getCoffeeShop() |
|
28 | + { |
|
29 | + return self::$coffee_shop; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param CoffeeShop $coffee_shop |
|
35 | - */ |
|
36 | - public static function setCoffeeShop(CoffeeShop $coffee_shop) |
|
37 | - { |
|
38 | - self::$coffee_shop = $coffee_shop; |
|
39 | - } |
|
33 | + /** |
|
34 | + * @param CoffeeShop $coffee_shop |
|
35 | + */ |
|
36 | + public static function setCoffeeShop(CoffeeShop $coffee_shop) |
|
37 | + { |
|
38 | + self::$coffee_shop = $coffee_shop; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @param string $identifier |
|
44 | - * @param array $arguments |
|
45 | - * @param string $type |
|
46 | - * @return mixed |
|
47 | - * @throws ServiceNotFoundException |
|
48 | - */ |
|
49 | - public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW) |
|
50 | - { |
|
51 | - return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
52 | - } |
|
42 | + /** |
|
43 | + * @param string $identifier |
|
44 | + * @param array $arguments |
|
45 | + * @param string $type |
|
46 | + * @return mixed |
|
47 | + * @throws ServiceNotFoundException |
|
48 | + */ |
|
49 | + public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW) |
|
50 | + { |
|
51 | + return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * IMPORTANT!!! |
|
57 | - * Usage of this method is discouraged as it promotes service location. |
|
58 | - * It's current use is only as a stop gap measure until the CoffeeShop |
|
59 | - * Dependency Injection Container can be implemented properly for all classes. |
|
60 | - * If it is at all possible, inject your dependencies via your class constructor. |
|
61 | - * This method WILL BE DEPRECATED at some point in the near future. |
|
62 | - * |
|
63 | - * @param string $identifier |
|
64 | - * @param array $arguments |
|
65 | - * @param string $type |
|
66 | - * @return mixed |
|
67 | - * @throws ServiceNotFoundException |
|
68 | - */ |
|
69 | - public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED) |
|
70 | - { |
|
71 | - return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
72 | - } |
|
55 | + /** |
|
56 | + * IMPORTANT!!! |
|
57 | + * Usage of this method is discouraged as it promotes service location. |
|
58 | + * It's current use is only as a stop gap measure until the CoffeeShop |
|
59 | + * Dependency Injection Container can be implemented properly for all classes. |
|
60 | + * If it is at all possible, inject your dependencies via your class constructor. |
|
61 | + * This method WILL BE DEPRECATED at some point in the near future. |
|
62 | + * |
|
63 | + * @param string $identifier |
|
64 | + * @param array $arguments |
|
65 | + * @param string $type |
|
66 | + * @return mixed |
|
67 | + * @throws ServiceNotFoundException |
|
68 | + */ |
|
69 | + public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED) |
|
70 | + { |
|
71 | + return self::$coffee_shop->brew($identifier, $arguments, $type); |
|
72 | + } |
|
73 | 73 | } |
@@ -15,25 +15,25 @@ |
||
15 | 15 | class InstantiationException extends BadMethodCallException |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * InstantiationException constructor. |
|
20 | - * |
|
21 | - * @param string $identifier the name of the requested entity or service |
|
22 | - * @param string $message |
|
23 | - * @param int $code |
|
24 | - * @param \Exception $previous |
|
25 | - */ |
|
26 | - public function __construct($identifier, $message = '', $code = 0, \Exception $previous = null) |
|
27 | - { |
|
28 | - if (empty($message)) { |
|
29 | - $message = sprintf( |
|
30 | - __( |
|
31 | - 'The "%1$s" class could not be constructed.', |
|
32 | - 'event_espresso' |
|
33 | - ), |
|
34 | - $identifier |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
18 | + /** |
|
19 | + * InstantiationException constructor. |
|
20 | + * |
|
21 | + * @param string $identifier the name of the requested entity or service |
|
22 | + * @param string $message |
|
23 | + * @param int $code |
|
24 | + * @param \Exception $previous |
|
25 | + */ |
|
26 | + public function __construct($identifier, $message = '', $code = 0, \Exception $previous = null) |
|
27 | + { |
|
28 | + if (empty($message)) { |
|
29 | + $message = sprintf( |
|
30 | + __( |
|
31 | + 'The "%1$s" class could not be constructed.', |
|
32 | + 'event_espresso' |
|
33 | + ), |
|
34 | + $identifier |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
@@ -14,26 +14,26 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * ServiceExistsException constructor |
|
19 | - * |
|
20 | - * @param string $service_name the name of the requested service |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param \Exception $previous |
|
24 | - */ |
|
25 | - public function __construct( |
|
26 | - $service_name, |
|
27 | - $message = '', |
|
28 | - $code = 0, |
|
29 | - \Exception $previous = null |
|
30 | - ) { |
|
31 | - if (empty($message)) { |
|
32 | - $message = sprintf( |
|
33 | - __('The "%1$s" service already exists in the CoffeeShop and can not be added again.', 'event_espresso'), |
|
34 | - $service_name |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
17 | + /** |
|
18 | + * ServiceExistsException constructor |
|
19 | + * |
|
20 | + * @param string $service_name the name of the requested service |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param \Exception $previous |
|
24 | + */ |
|
25 | + public function __construct( |
|
26 | + $service_name, |
|
27 | + $message = '', |
|
28 | + $code = 0, |
|
29 | + \Exception $previous = null |
|
30 | + ) { |
|
31 | + if (empty($message)) { |
|
32 | + $message = sprintf( |
|
33 | + __('The "%1$s" service already exists in the CoffeeShop and can not be added again.', 'event_espresso'), |
|
34 | + $service_name |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
@@ -12,26 +12,26 @@ |
||
12 | 12 | class ServiceNotFoundException extends \RuntimeException |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * ServiceNotFoundException constructor |
|
17 | - * |
|
18 | - * @param string $service_name the name of the requested service |
|
19 | - * @param string $message |
|
20 | - * @param int $code |
|
21 | - * @param \Exception $previous |
|
22 | - */ |
|
23 | - public function __construct( |
|
24 | - $service_name, |
|
25 | - $message = '', |
|
26 | - $code = 0, |
|
27 | - \Exception $previous = null |
|
28 | - ) { |
|
29 | - if (empty($message)) { |
|
30 | - $message = sprintf( |
|
31 | - __('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'), |
|
32 | - $service_name |
|
33 | - ); |
|
34 | - } |
|
35 | - parent::__construct($message, $code, $previous); |
|
36 | - } |
|
15 | + /** |
|
16 | + * ServiceNotFoundException constructor |
|
17 | + * |
|
18 | + * @param string $service_name the name of the requested service |
|
19 | + * @param string $message |
|
20 | + * @param int $code |
|
21 | + * @param \Exception $previous |
|
22 | + */ |
|
23 | + public function __construct( |
|
24 | + $service_name, |
|
25 | + $message = '', |
|
26 | + $code = 0, |
|
27 | + \Exception $previous = null |
|
28 | + ) { |
|
29 | + if (empty($message)) { |
|
30 | + $message = sprintf( |
|
31 | + __('The requested service "%1$s" could not found be found in the CoffeeShop.', 'event_espresso'), |
|
32 | + $service_name |
|
33 | + ); |
|
34 | + } |
|
35 | + parent::__construct($message, $code, $previous); |
|
36 | + } |
|
37 | 37 | } |
@@ -13,27 +13,27 @@ |
||
13 | 13 | class InvalidServiceException extends \UnexpectedValueException |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * InvalidServiceException constructor. |
|
18 | - * |
|
19 | - * @param string $service_name the name of the requested service |
|
20 | - * @param string $actual classname of what we got |
|
21 | - * @param string $message |
|
22 | - * @param int $code |
|
23 | - * @param \Exception $previous |
|
24 | - */ |
|
25 | - public function __construct($service_name, $actual, $message = '', $code = 0, \Exception $previous = null) |
|
26 | - { |
|
27 | - if (empty($message)) { |
|
28 | - $message = sprintf( |
|
29 | - __( |
|
30 | - 'The "%1$s" service could not be retrieved from the CoffeeShop, but "%2$s" was received.', |
|
31 | - 'event_espresso' |
|
32 | - ), |
|
33 | - $service_name, |
|
34 | - print_r($actual, true) |
|
35 | - ); |
|
36 | - } |
|
37 | - parent::__construct($message, $code, $previous); |
|
38 | - } |
|
16 | + /** |
|
17 | + * InvalidServiceException constructor. |
|
18 | + * |
|
19 | + * @param string $service_name the name of the requested service |
|
20 | + * @param string $actual classname of what we got |
|
21 | + * @param string $message |
|
22 | + * @param int $code |
|
23 | + * @param \Exception $previous |
|
24 | + */ |
|
25 | + public function __construct($service_name, $actual, $message = '', $code = 0, \Exception $previous = null) |
|
26 | + { |
|
27 | + if (empty($message)) { |
|
28 | + $message = sprintf( |
|
29 | + __( |
|
30 | + 'The "%1$s" service could not be retrieved from the CoffeeShop, but "%2$s" was received.', |
|
31 | + 'event_espresso' |
|
32 | + ), |
|
33 | + $service_name, |
|
34 | + print_r($actual, true) |
|
35 | + ); |
|
36 | + } |
|
37 | + parent::__construct($message, $code, $previous); |
|
38 | + } |
|
39 | 39 | } |
@@ -20,51 +20,51 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function type() |
|
27 | - { |
|
28 | - return CoffeeMaker::BREW_NEW; |
|
29 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function type() |
|
27 | + { |
|
28 | + return CoffeeMaker::BREW_NEW; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * @param RecipeInterface $recipe |
|
34 | - * @param array $arguments |
|
35 | - * @return mixed |
|
36 | - */ |
|
37 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
38 | - { |
|
39 | - $this->resolveClassAndFilepath($recipe); |
|
40 | - $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
41 | - $method = $this->resolveInstantiationMethod($reflector); |
|
42 | - switch ($method) { |
|
43 | - case 'instance': |
|
44 | - case 'new_instance': |
|
45 | - case 'new_instance_from_db': |
|
46 | - $injector = $this->injector(); |
|
47 | - $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
48 | - return call_user_func_array( |
|
49 | - array($reflector->getName(), $method), |
|
50 | - $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
51 | - ); |
|
52 | - }; |
|
53 | - break; |
|
54 | - case 'newInstance': |
|
55 | - $closure = function () use ($reflector) { |
|
56 | - return $reflector->newInstance(); |
|
57 | - }; |
|
58 | - break; |
|
59 | - case 'newInstanceArgs': |
|
60 | - default: |
|
61 | - $injector = $this->injector(); |
|
62 | - $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
63 | - return $reflector->newInstanceArgs( |
|
64 | - $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
65 | - ); |
|
66 | - }; |
|
67 | - } |
|
68 | - return $this->coffeePot()->addClosure($recipe->identifier(), $closure); |
|
69 | - } |
|
32 | + /** |
|
33 | + * @param RecipeInterface $recipe |
|
34 | + * @param array $arguments |
|
35 | + * @return mixed |
|
36 | + */ |
|
37 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
38 | + { |
|
39 | + $this->resolveClassAndFilepath($recipe); |
|
40 | + $reflector = $this->injector()->getReflectionClass($recipe->fqcn()); |
|
41 | + $method = $this->resolveInstantiationMethod($reflector); |
|
42 | + switch ($method) { |
|
43 | + case 'instance': |
|
44 | + case 'new_instance': |
|
45 | + case 'new_instance_from_db': |
|
46 | + $injector = $this->injector(); |
|
47 | + $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
48 | + return call_user_func_array( |
|
49 | + array($reflector->getName(), $method), |
|
50 | + $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
51 | + ); |
|
52 | + }; |
|
53 | + break; |
|
54 | + case 'newInstance': |
|
55 | + $closure = function () use ($reflector) { |
|
56 | + return $reflector->newInstance(); |
|
57 | + }; |
|
58 | + break; |
|
59 | + case 'newInstanceArgs': |
|
60 | + default: |
|
61 | + $injector = $this->injector(); |
|
62 | + $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
63 | + return $reflector->newInstanceArgs( |
|
64 | + $injector->resolveDependencies($recipe, $reflector, $arguments) |
|
65 | + ); |
|
66 | + }; |
|
67 | + } |
|
68 | + return $this->coffeePot()->addClosure($recipe->identifier(), $closure); |
|
69 | + } |
|
70 | 70 | } |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | case 'new_instance': |
45 | 45 | case 'new_instance_from_db': |
46 | 46 | $injector = $this->injector(); |
47 | - $closure = function ($arguments) use ($recipe, $reflector, $method, $injector) { |
|
47 | + $closure = function($arguments) use ($recipe, $reflector, $method, $injector) { |
|
48 | 48 | return call_user_func_array( |
49 | 49 | array($reflector->getName(), $method), |
50 | 50 | $injector->resolveDependencies($recipe, $reflector, $arguments) |
@@ -52,14 +52,14 @@ discard block |
||
52 | 52 | }; |
53 | 53 | break; |
54 | 54 | case 'newInstance': |
55 | - $closure = function () use ($reflector) { |
|
55 | + $closure = function() use ($reflector) { |
|
56 | 56 | return $reflector->newInstance(); |
57 | 57 | }; |
58 | 58 | break; |
59 | 59 | case 'newInstanceArgs': |
60 | 60 | default: |
61 | 61 | $injector = $this->injector(); |
62 | - $closure = function ($arguments) use ($recipe, $reflector, $injector) { |
|
62 | + $closure = function($arguments) use ($recipe, $reflector, $injector) { |
|
63 | 63 | return $reflector->newInstanceArgs( |
64 | 64 | $injector->resolveDependencies($recipe, $reflector, $arguments) |
65 | 65 | ); |
@@ -21,23 +21,23 @@ |
||
21 | 21 | class LoadOnlyCoffeeMaker extends CoffeeMaker |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function type() |
|
28 | - { |
|
29 | - return CoffeeMaker::BREW_LOAD_ONLY; |
|
30 | - } |
|
24 | + /** |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function type() |
|
28 | + { |
|
29 | + return CoffeeMaker::BREW_LOAD_ONLY; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @param RecipeInterface $recipe |
|
35 | - * @param array $arguments |
|
36 | - * @return mixed |
|
37 | - * @throws InvalidClassException |
|
38 | - */ |
|
39 | - public function brew(RecipeInterface $recipe, $arguments = array()) |
|
40 | - { |
|
41 | - return $this->resolveClassAndFilepath($recipe); |
|
42 | - } |
|
33 | + /** |
|
34 | + * @param RecipeInterface $recipe |
|
35 | + * @param array $arguments |
|
36 | + * @return mixed |
|
37 | + * @throws InvalidClassException |
|
38 | + */ |
|
39 | + public function brew(RecipeInterface $recipe, $arguments = array()) |
|
40 | + { |
|
41 | + return $this->resolveClassAndFilepath($recipe); |
|
42 | + } |
|
43 | 43 | } |
@@ -14,115 +14,115 @@ |
||
14 | 14 | class GatewayDataFormatter implements GatewayDataFormatterInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Gets the text to use for a gateway's line item name when this is a partial payment |
|
19 | - * |
|
20 | - * @param \EEI_Payment $payment |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function formatPartialPaymentLineItemName(\EEI_Payment $payment) |
|
24 | - { |
|
25 | - return apply_filters( |
|
26 | - 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
|
27 | - $payment->get_first_event_name(), |
|
28 | - $this, |
|
29 | - $payment |
|
30 | - ); |
|
31 | - } |
|
17 | + /** |
|
18 | + * Gets the text to use for a gateway's line item name when this is a partial payment |
|
19 | + * |
|
20 | + * @param \EEI_Payment $payment |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function formatPartialPaymentLineItemName(\EEI_Payment $payment) |
|
24 | + { |
|
25 | + return apply_filters( |
|
26 | + 'EEG_Paypal_Pro__do_direct_payment__partial_amount_line_item_name', |
|
27 | + $payment->get_first_event_name(), |
|
28 | + $this, |
|
29 | + $payment |
|
30 | + ); |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * Gets the text to use for a gateway's line item description when this is a partial payment |
|
36 | - * |
|
37 | - * @param \EEI_Payment $payment |
|
38 | - * @return string |
|
39 | - */ |
|
40 | - public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment) |
|
41 | - { |
|
42 | - return apply_filters( |
|
43 | - 'FHEE__EE_Gateway___partial_payment_desc', |
|
44 | - sprintf( |
|
45 | - __('Payment of %1$s for %2$s', "event_espresso"), |
|
46 | - $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
47 | - $payment->get_first_event_name() |
|
48 | - ), |
|
49 | - $this, |
|
50 | - $payment |
|
51 | - ); |
|
52 | - } |
|
34 | + /** |
|
35 | + * Gets the text to use for a gateway's line item description when this is a partial payment |
|
36 | + * |
|
37 | + * @param \EEI_Payment $payment |
|
38 | + * @return string |
|
39 | + */ |
|
40 | + public function formatPartialPaymentLineItemDesc(\EEI_Payment $payment) |
|
41 | + { |
|
42 | + return apply_filters( |
|
43 | + 'FHEE__EE_Gateway___partial_payment_desc', |
|
44 | + sprintf( |
|
45 | + __('Payment of %1$s for %2$s', "event_espresso"), |
|
46 | + $payment->get_pretty('PAY_amount', 'no_currency_code'), |
|
47 | + $payment->get_first_event_name() |
|
48 | + ), |
|
49 | + $this, |
|
50 | + $payment |
|
51 | + ); |
|
52 | + } |
|
53 | 53 | |
54 | 54 | |
55 | - /** |
|
56 | - * Gets the name to use for a line item when sending line items to the gateway |
|
57 | - * |
|
58 | - * @param \EEI_Line_Item $line_item |
|
59 | - * @param \EEI_Payment $payment |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
63 | - { |
|
64 | - return apply_filters( |
|
65 | - 'FHEE__EE_gateway___line_item_name', |
|
66 | - sprintf( |
|
67 | - _x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), |
|
68 | - $line_item->name(), |
|
69 | - $line_item->ticket_event_name() |
|
70 | - ), |
|
71 | - $this, |
|
72 | - $line_item, |
|
73 | - $payment |
|
74 | - ); |
|
75 | - } |
|
55 | + /** |
|
56 | + * Gets the name to use for a line item when sending line items to the gateway |
|
57 | + * |
|
58 | + * @param \EEI_Line_Item $line_item |
|
59 | + * @param \EEI_Payment $payment |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function formatLineItemName(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
63 | + { |
|
64 | + return apply_filters( |
|
65 | + 'FHEE__EE_gateway___line_item_name', |
|
66 | + sprintf( |
|
67 | + _x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), |
|
68 | + $line_item->name(), |
|
69 | + $line_item->ticket_event_name() |
|
70 | + ), |
|
71 | + $this, |
|
72 | + $line_item, |
|
73 | + $payment |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * Gets the description to use for a line item when sending line items to the gateway |
|
80 | - * |
|
81 | - * @param \EEI_Line_Item $line_item |
|
82 | - * @param \EEI_Payment $payment |
|
83 | - * @return string |
|
84 | - */ |
|
85 | - public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
86 | - { |
|
87 | - return apply_filters( |
|
88 | - 'FHEE__EE_Gateway___line_item_desc', |
|
89 | - $line_item->desc(), |
|
90 | - $this, |
|
91 | - $line_item, |
|
92 | - $payment |
|
93 | - ); |
|
94 | - } |
|
78 | + /** |
|
79 | + * Gets the description to use for a line item when sending line items to the gateway |
|
80 | + * |
|
81 | + * @param \EEI_Line_Item $line_item |
|
82 | + * @param \EEI_Payment $payment |
|
83 | + * @return string |
|
84 | + */ |
|
85 | + public function formatLineItemDesc(\EEI_Line_Item $line_item, \EEI_Payment $payment) |
|
86 | + { |
|
87 | + return apply_filters( |
|
88 | + 'FHEE__EE_Gateway___line_item_desc', |
|
89 | + $line_item->desc(), |
|
90 | + $this, |
|
91 | + $line_item, |
|
92 | + $payment |
|
93 | + ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | - /** |
|
98 | - * Gets the order description that should generally be sent to gateways |
|
99 | - * |
|
100 | - * @param \EEI_Payment $payment |
|
101 | - * @return string |
|
102 | - */ |
|
103 | - public function formatOrderDescription(\EEI_Payment $payment) |
|
104 | - { |
|
105 | - return apply_filters( |
|
106 | - 'FHEE__EE_Gateway___order_description', |
|
107 | - sprintf( |
|
108 | - __('Event Registrations from %1$s for %2$s', "event_espresso"), |
|
109 | - wp_specialchars_decode(get_bloginfo(), ENT_QUOTES), |
|
110 | - $payment->get_first_event_name() |
|
111 | - ), |
|
112 | - $this, |
|
113 | - $payment |
|
114 | - ); |
|
115 | - } |
|
97 | + /** |
|
98 | + * Gets the order description that should generally be sent to gateways |
|
99 | + * |
|
100 | + * @param \EEI_Payment $payment |
|
101 | + * @return string |
|
102 | + */ |
|
103 | + public function formatOrderDescription(\EEI_Payment $payment) |
|
104 | + { |
|
105 | + return apply_filters( |
|
106 | + 'FHEE__EE_Gateway___order_description', |
|
107 | + sprintf( |
|
108 | + __('Event Registrations from %1$s for %2$s', "event_espresso"), |
|
109 | + wp_specialchars_decode(get_bloginfo(), ENT_QUOTES), |
|
110 | + $payment->get_first_event_name() |
|
111 | + ), |
|
112 | + $this, |
|
113 | + $payment |
|
114 | + ); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
119 | - * Formats the amount so it can generally be sent to gateways |
|
120 | - * |
|
121 | - * @param float $amount |
|
122 | - * @return string |
|
123 | - */ |
|
124 | - public function formatCurrency($amount) |
|
125 | - { |
|
126 | - return number_format($amount, 2, '.', ''); |
|
127 | - } |
|
118 | + /** |
|
119 | + * Formats the amount so it can generally be sent to gateways |
|
120 | + * |
|
121 | + * @param float $amount |
|
122 | + * @return string |
|
123 | + */ |
|
124 | + public function formatCurrency($amount) |
|
125 | + { |
|
126 | + return number_format($amount, 2, '.', ''); |
|
127 | + } |
|
128 | 128 | } |