@@ -17,43 +17,43 @@ |
||
17 | 17 | abstract class Locator implements LocatorInterface, Countable |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @var array $flags |
|
22 | - */ |
|
23 | - protected $flags = array(); |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * FileLocator constructor. |
|
28 | - * |
|
29 | - * @access public |
|
30 | - * @param array $flags controls how files are found and/or file data is returned |
|
31 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
32 | - */ |
|
33 | - public function __construct($flags = array()) |
|
34 | - { |
|
35 | - if (empty($flags)) { |
|
36 | - $flags = array( |
|
37 | - FilesystemIterator::SKIP_DOTS, |
|
38 | - FilesystemIterator::UNIX_PATHS, |
|
39 | - FilesystemIterator::CURRENT_AS_PATHNAME, |
|
40 | - ); |
|
41 | - } |
|
42 | - $this->setFlags($flags); |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @see http://php.net/manual/en/class.filesystemiterator.php#filesystemiterator.constants |
|
48 | - * @access public |
|
49 | - * @param array $flags |
|
50 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
51 | - */ |
|
52 | - public function setFlags($flags) |
|
53 | - { |
|
54 | - if (! is_array($flags)) { |
|
55 | - throw new InvalidDataTypeException('$flags', $flags, 'array'); |
|
56 | - } |
|
57 | - $this->flags = $flags; |
|
58 | - } |
|
20 | + /** |
|
21 | + * @var array $flags |
|
22 | + */ |
|
23 | + protected $flags = array(); |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * FileLocator constructor. |
|
28 | + * |
|
29 | + * @access public |
|
30 | + * @param array $flags controls how files are found and/or file data is returned |
|
31 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
32 | + */ |
|
33 | + public function __construct($flags = array()) |
|
34 | + { |
|
35 | + if (empty($flags)) { |
|
36 | + $flags = array( |
|
37 | + FilesystemIterator::SKIP_DOTS, |
|
38 | + FilesystemIterator::UNIX_PATHS, |
|
39 | + FilesystemIterator::CURRENT_AS_PATHNAME, |
|
40 | + ); |
|
41 | + } |
|
42 | + $this->setFlags($flags); |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @see http://php.net/manual/en/class.filesystemiterator.php#filesystemiterator.constants |
|
48 | + * @access public |
|
49 | + * @param array $flags |
|
50 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
51 | + */ |
|
52 | + public function setFlags($flags) |
|
53 | + { |
|
54 | + if (! is_array($flags)) { |
|
55 | + throw new InvalidDataTypeException('$flags', $flags, 'array'); |
|
56 | + } |
|
57 | + $this->flags = $flags; |
|
58 | + } |
|
59 | 59 | } |
@@ -51,7 +51,7 @@ |
||
51 | 51 | */ |
52 | 52 | public function setFlags($flags) |
53 | 53 | { |
54 | - if (! is_array($flags)) { |
|
54 | + if ( ! is_array($flags)) { |
|
55 | 55 | throw new InvalidDataTypeException('$flags', $flags, 'array'); |
56 | 56 | } |
57 | 57 | $this->flags = $flags; |
@@ -29,203 +29,203 @@ |
||
29 | 29 | class ShortcodesManager |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
34 | - */ |
|
35 | - private $legacy_shortcodes_manager; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var ShortcodeInterface[] $shortcodes |
|
39 | - */ |
|
40 | - private $shortcodes; |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * ShortcodesManager constructor |
|
45 | - * |
|
46 | - * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
47 | - */ |
|
48 | - public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) |
|
49 | - { |
|
50 | - $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
51 | - // assemble a list of installed and active shortcodes |
|
52 | - add_action( |
|
53 | - 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
54 | - array($this, 'registerShortcodes'), |
|
55 | - 999 |
|
56 | - ); |
|
57 | - // call add_shortcode() for all installed shortcodes |
|
58 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
59 | - // check content for shortcodes the old way |
|
60 | - add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
61 | - // check content for shortcodes the NEW more efficient way |
|
62 | - add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return CollectionInterface|ShortcodeInterface[] |
|
68 | - * @throws InvalidIdentifierException |
|
69 | - * @throws InvalidInterfaceException |
|
70 | - * @throws InvalidFilePathException |
|
71 | - * @throws InvalidEntityException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidClassException |
|
74 | - */ |
|
75 | - public function getShortcodes() |
|
76 | - { |
|
77 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
78 | - $this->shortcodes = $this->loadShortcodesCollection(); |
|
79 | - } |
|
80 | - return $this->shortcodes; |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @return CollectionInterface|ShortcodeInterface[] |
|
86 | - * @throws InvalidIdentifierException |
|
87 | - * @throws InvalidInterfaceException |
|
88 | - * @throws InvalidFilePathException |
|
89 | - * @throws InvalidEntityException |
|
90 | - * @throws InvalidDataTypeException |
|
91 | - * @throws InvalidClassException |
|
92 | - */ |
|
93 | - protected function loadShortcodesCollection() |
|
94 | - { |
|
95 | - $loader = new CollectionLoader( |
|
96 | - new CollectionDetails( |
|
97 | - // collection name |
|
98 | - 'shortcodes', |
|
99 | - // collection interface |
|
100 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
101 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
102 | - array('EventEspresso\core\domain\entities\shortcodes'), |
|
103 | - // filepaths to classes to add |
|
104 | - array(), |
|
105 | - // file mask to use if parsing folder for files to add |
|
106 | - '', |
|
107 | - // what to use as identifier for collection entities |
|
108 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
109 | - CollectionDetails::ID_CLASS_NAME |
|
110 | - ) |
|
111 | - ); |
|
112 | - return $loader->getCollection(); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @return void |
|
118 | - * @throws DomainException |
|
119 | - * @throws InvalidInterfaceException |
|
120 | - * @throws InvalidIdentifierException |
|
121 | - * @throws InvalidFilePathException |
|
122 | - * @throws InvalidEntityException |
|
123 | - * @throws InvalidDataTypeException |
|
124 | - * @throws InvalidClassException |
|
125 | - */ |
|
126 | - public function registerShortcodes() |
|
127 | - { |
|
128 | - try { |
|
129 | - $this->shortcodes = apply_filters( |
|
130 | - 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
131 | - $this->getShortcodes() |
|
132 | - ); |
|
133 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
134 | - throw new InvalidEntityException( |
|
135 | - $this->shortcodes, |
|
136 | - 'CollectionInterface', |
|
137 | - sprintf( |
|
138 | - esc_html__( |
|
139 | - 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
140 | - 'event_espresso' |
|
141 | - ), |
|
142 | - is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
143 | - ) |
|
144 | - ); |
|
145 | - } |
|
146 | - $this->legacy_shortcodes_manager->registerShortcodes(); |
|
147 | - } catch (Exception $exception) { |
|
148 | - new ExceptionStackTraceDisplay($exception); |
|
149 | - } |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - public function addShortcodes() |
|
157 | - { |
|
158 | - try { |
|
159 | - // cycle thru shortcode folders |
|
160 | - foreach ($this->shortcodes as $shortcode) { |
|
161 | - /** @var ShortcodeInterface $shortcode */ |
|
162 | - if ($shortcode instanceof EnqueueAssetsInterface) { |
|
163 | - add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
164 | - add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
165 | - } |
|
166 | - // add_shortcode() if it has not already been added |
|
167 | - if (! shortcode_exists($shortcode->getTag())) { |
|
168 | - add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
169 | - } |
|
170 | - } |
|
171 | - $this->legacy_shortcodes_manager->addShortcodes(); |
|
172 | - } catch (Exception $exception) { |
|
173 | - new ExceptionStackTraceDisplay($exception); |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * callback for the "template_redirect" hook point |
|
180 | - * checks posts for EE shortcodes, and initializes them, |
|
181 | - * then toggles filter switch that loads core default assets |
|
182 | - * |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function templateRedirect() |
|
186 | - { |
|
187 | - global $wp_query; |
|
188 | - if (empty($wp_query->posts)) { |
|
189 | - return; |
|
190 | - } |
|
191 | - $load_assets = false; |
|
192 | - // array of posts displayed in current request |
|
193 | - $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
194 | - foreach ($posts as $post) { |
|
195 | - // now check post content and excerpt for EE shortcodes |
|
196 | - $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
197 | - ? true |
|
198 | - : $load_assets; |
|
199 | - } |
|
200 | - if ($load_assets) { |
|
201 | - $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
202 | - add_filter('FHEE_load_css', '__return_true'); |
|
203 | - add_filter('FHEE_load_js', '__return_true'); |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * checks supplied content against list of shortcodes, |
|
210 | - * then initializes any found shortcodes, and returns true. |
|
211 | - * returns false if no shortcodes found. |
|
212 | - * |
|
213 | - * @param string $content |
|
214 | - * @return bool |
|
215 | - */ |
|
216 | - public function parseContentForShortcodes($content) |
|
217 | - { |
|
218 | - $has_shortcode = false; |
|
219 | - if (empty($this->shortcodes)) { |
|
220 | - return $has_shortcode; |
|
221 | - } |
|
222 | - foreach ($this->shortcodes as $shortcode) { |
|
223 | - /** @var ShortcodeInterface $shortcode */ |
|
224 | - if (has_shortcode($content, $shortcode->getTag())) { |
|
225 | - $shortcode->initializeShortcode(); |
|
226 | - $has_shortcode = true; |
|
227 | - } |
|
228 | - } |
|
229 | - return $has_shortcode; |
|
230 | - } |
|
32 | + /** |
|
33 | + * @var LegacyShortcodesManager $legacy_shortcodes_manager |
|
34 | + */ |
|
35 | + private $legacy_shortcodes_manager; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var ShortcodeInterface[] $shortcodes |
|
39 | + */ |
|
40 | + private $shortcodes; |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * ShortcodesManager constructor |
|
45 | + * |
|
46 | + * @param LegacyShortcodesManager $legacy_shortcodes_manager |
|
47 | + */ |
|
48 | + public function __construct(LegacyShortcodesManager $legacy_shortcodes_manager) |
|
49 | + { |
|
50 | + $this->legacy_shortcodes_manager = $legacy_shortcodes_manager; |
|
51 | + // assemble a list of installed and active shortcodes |
|
52 | + add_action( |
|
53 | + 'AHEE__EE_System__register_shortcodes_modules_and_widgets', |
|
54 | + array($this, 'registerShortcodes'), |
|
55 | + 999 |
|
56 | + ); |
|
57 | + // call add_shortcode() for all installed shortcodes |
|
58 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'addShortcodes')); |
|
59 | + // check content for shortcodes the old way |
|
60 | + add_action('parse_query', array($this->legacy_shortcodes_manager, 'initializeShortcodes'), 5); |
|
61 | + // check content for shortcodes the NEW more efficient way |
|
62 | + add_action('template_redirect', array($this, 'templateRedirect'), 999); |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return CollectionInterface|ShortcodeInterface[] |
|
68 | + * @throws InvalidIdentifierException |
|
69 | + * @throws InvalidInterfaceException |
|
70 | + * @throws InvalidFilePathException |
|
71 | + * @throws InvalidEntityException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidClassException |
|
74 | + */ |
|
75 | + public function getShortcodes() |
|
76 | + { |
|
77 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
78 | + $this->shortcodes = $this->loadShortcodesCollection(); |
|
79 | + } |
|
80 | + return $this->shortcodes; |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @return CollectionInterface|ShortcodeInterface[] |
|
86 | + * @throws InvalidIdentifierException |
|
87 | + * @throws InvalidInterfaceException |
|
88 | + * @throws InvalidFilePathException |
|
89 | + * @throws InvalidEntityException |
|
90 | + * @throws InvalidDataTypeException |
|
91 | + * @throws InvalidClassException |
|
92 | + */ |
|
93 | + protected function loadShortcodesCollection() |
|
94 | + { |
|
95 | + $loader = new CollectionLoader( |
|
96 | + new CollectionDetails( |
|
97 | + // collection name |
|
98 | + 'shortcodes', |
|
99 | + // collection interface |
|
100 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
101 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
102 | + array('EventEspresso\core\domain\entities\shortcodes'), |
|
103 | + // filepaths to classes to add |
|
104 | + array(), |
|
105 | + // file mask to use if parsing folder for files to add |
|
106 | + '', |
|
107 | + // what to use as identifier for collection entities |
|
108 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
109 | + CollectionDetails::ID_CLASS_NAME |
|
110 | + ) |
|
111 | + ); |
|
112 | + return $loader->getCollection(); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @return void |
|
118 | + * @throws DomainException |
|
119 | + * @throws InvalidInterfaceException |
|
120 | + * @throws InvalidIdentifierException |
|
121 | + * @throws InvalidFilePathException |
|
122 | + * @throws InvalidEntityException |
|
123 | + * @throws InvalidDataTypeException |
|
124 | + * @throws InvalidClassException |
|
125 | + */ |
|
126 | + public function registerShortcodes() |
|
127 | + { |
|
128 | + try { |
|
129 | + $this->shortcodes = apply_filters( |
|
130 | + 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
|
131 | + $this->getShortcodes() |
|
132 | + ); |
|
133 | + if (! $this->shortcodes instanceof CollectionInterface) { |
|
134 | + throw new InvalidEntityException( |
|
135 | + $this->shortcodes, |
|
136 | + 'CollectionInterface', |
|
137 | + sprintf( |
|
138 | + esc_html__( |
|
139 | + 'The "FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection" filter must return a Collection of EspressoShortcode objects. "%1$s" was received instead.', |
|
140 | + 'event_espresso' |
|
141 | + ), |
|
142 | + is_object($this->shortcodes) ? get_class($this->shortcodes) : gettype($this->shortcodes) |
|
143 | + ) |
|
144 | + ); |
|
145 | + } |
|
146 | + $this->legacy_shortcodes_manager->registerShortcodes(); |
|
147 | + } catch (Exception $exception) { |
|
148 | + new ExceptionStackTraceDisplay($exception); |
|
149 | + } |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + public function addShortcodes() |
|
157 | + { |
|
158 | + try { |
|
159 | + // cycle thru shortcode folders |
|
160 | + foreach ($this->shortcodes as $shortcode) { |
|
161 | + /** @var ShortcodeInterface $shortcode */ |
|
162 | + if ($shortcode instanceof EnqueueAssetsInterface) { |
|
163 | + add_action('wp_enqueue_scripts', array($shortcode, 'registerScriptsAndStylesheets'), 10); |
|
164 | + add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
|
165 | + } |
|
166 | + // add_shortcode() if it has not already been added |
|
167 | + if (! shortcode_exists($shortcode->getTag())) { |
|
168 | + add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
|
169 | + } |
|
170 | + } |
|
171 | + $this->legacy_shortcodes_manager->addShortcodes(); |
|
172 | + } catch (Exception $exception) { |
|
173 | + new ExceptionStackTraceDisplay($exception); |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * callback for the "template_redirect" hook point |
|
180 | + * checks posts for EE shortcodes, and initializes them, |
|
181 | + * then toggles filter switch that loads core default assets |
|
182 | + * |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function templateRedirect() |
|
186 | + { |
|
187 | + global $wp_query; |
|
188 | + if (empty($wp_query->posts)) { |
|
189 | + return; |
|
190 | + } |
|
191 | + $load_assets = false; |
|
192 | + // array of posts displayed in current request |
|
193 | + $posts = is_array($wp_query->posts) ? $wp_query->posts : array($wp_query->posts); |
|
194 | + foreach ($posts as $post) { |
|
195 | + // now check post content and excerpt for EE shortcodes |
|
196 | + $load_assets = $this->parseContentForShortcodes($post->post_content) |
|
197 | + ? true |
|
198 | + : $load_assets; |
|
199 | + } |
|
200 | + if ($load_assets) { |
|
201 | + $this->legacy_shortcodes_manager->registry()->REQ->set_espresso_page(true); |
|
202 | + add_filter('FHEE_load_css', '__return_true'); |
|
203 | + add_filter('FHEE_load_js', '__return_true'); |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * checks supplied content against list of shortcodes, |
|
210 | + * then initializes any found shortcodes, and returns true. |
|
211 | + * returns false if no shortcodes found. |
|
212 | + * |
|
213 | + * @param string $content |
|
214 | + * @return bool |
|
215 | + */ |
|
216 | + public function parseContentForShortcodes($content) |
|
217 | + { |
|
218 | + $has_shortcode = false; |
|
219 | + if (empty($this->shortcodes)) { |
|
220 | + return $has_shortcode; |
|
221 | + } |
|
222 | + foreach ($this->shortcodes as $shortcode) { |
|
223 | + /** @var ShortcodeInterface $shortcode */ |
|
224 | + if (has_shortcode($content, $shortcode->getTag())) { |
|
225 | + $shortcode->initializeShortcode(); |
|
226 | + $has_shortcode = true; |
|
227 | + } |
|
228 | + } |
|
229 | + return $has_shortcode; |
|
230 | + } |
|
231 | 231 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function getShortcodes() |
76 | 76 | { |
77 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
77 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
78 | 78 | $this->shortcodes = $this->loadShortcodesCollection(); |
79 | 79 | } |
80 | 80 | return $this->shortcodes; |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | 'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection', |
131 | 131 | $this->getShortcodes() |
132 | 132 | ); |
133 | - if (! $this->shortcodes instanceof CollectionInterface) { |
|
133 | + if ( ! $this->shortcodes instanceof CollectionInterface) { |
|
134 | 134 | throw new InvalidEntityException( |
135 | 135 | $this->shortcodes, |
136 | 136 | 'CollectionInterface', |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | add_action('wp_enqueue_scripts', array($shortcode, 'enqueueStylesheets'), 11); |
165 | 165 | } |
166 | 166 | // add_shortcode() if it has not already been added |
167 | - if (! shortcode_exists($shortcode->getTag())) { |
|
167 | + if ( ! shortcode_exists($shortcode->getTag())) { |
|
168 | 168 | add_shortcode($shortcode->getTag(), array($shortcode, 'processShortcodeCallback')); |
169 | 169 | } |
170 | 170 | } |
@@ -12,38 +12,38 @@ |
||
12 | 12 | */ |
13 | 13 | class AddressFormatter |
14 | 14 | { |
15 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $formatted_address |
|
24 | - * @param string $sub |
|
25 | - * @return mixed |
|
26 | - */ |
|
27 | - protected function parse_formatted_address( |
|
28 | - $address, |
|
29 | - $address2, |
|
30 | - $city, |
|
31 | - $state, |
|
32 | - $zip, |
|
33 | - $country, |
|
34 | - $formatted_address, |
|
35 | - $sub |
|
36 | - ) { |
|
37 | - // swap address part placeholders for the real text |
|
38 | - $formatted_address = str_replace( |
|
39 | - // find |
|
40 | - array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | - // replace |
|
42 | - array($address, $address2, $city, $state, $zip, $country), |
|
43 | - // string |
|
44 | - $formatted_address |
|
45 | - ); |
|
46 | - // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | - return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | - } |
|
15 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $formatted_address |
|
24 | + * @param string $sub |
|
25 | + * @return mixed |
|
26 | + */ |
|
27 | + protected function parse_formatted_address( |
|
28 | + $address, |
|
29 | + $address2, |
|
30 | + $city, |
|
31 | + $state, |
|
32 | + $zip, |
|
33 | + $country, |
|
34 | + $formatted_address, |
|
35 | + $sub |
|
36 | + ) { |
|
37 | + // swap address part placeholders for the real text |
|
38 | + $formatted_address = str_replace( |
|
39 | + // find |
|
40 | + array('{address}', '{address2}', '{city}', '{state}', '{zip}', '{country}'), |
|
41 | + // replace |
|
42 | + array($address, $address2, $city, $state, $zip, $country), |
|
43 | + // string |
|
44 | + $formatted_address |
|
45 | + ); |
|
46 | + // remove placeholder from start and end, reduce repeating placeholders to singles, then replace with HTML line breaks |
|
47 | + return preg_replace('/%+/', $sub, trim($formatted_address, '%')); |
|
48 | + } |
|
49 | 49 | } |
@@ -13,18 +13,18 @@ |
||
13 | 13 | class NullAddressFormatter implements \EEI_Address_Formatter |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param string $address |
|
18 | - * @param string $address2 |
|
19 | - * @param string $city |
|
20 | - * @param string $state |
|
21 | - * @param string $zip |
|
22 | - * @param string $country |
|
23 | - * @param string $CNT_ISO |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) |
|
27 | - { |
|
28 | - return null; |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param string $address |
|
18 | + * @param string $address2 |
|
19 | + * @param string $city |
|
20 | + * @param string $state |
|
21 | + * @param string $zip |
|
22 | + * @param string $country |
|
23 | + * @param string $CNT_ISO |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) |
|
27 | + { |
|
28 | + return null; |
|
29 | + } |
|
30 | 30 | } |
@@ -18,36 +18,36 @@ |
||
18 | 18 | { |
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * @var LoaderInterface $loader |
|
23 | - */ |
|
24 | - private $loader; |
|
25 | - |
|
26 | - |
|
27 | - /** |
|
28 | - * CommandFactory constructor |
|
29 | - * |
|
30 | - * @param LoaderInterface $loader |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - * @throws InvalidInterfaceException |
|
33 | - * @throws InvalidArgumentException |
|
34 | - */ |
|
35 | - public function __construct(LoaderInterface $loader = null) |
|
36 | - { |
|
37 | - $this->loader = $loader; |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * @param string $command_fqcn |
|
43 | - * @param array $arguments |
|
44 | - * @return mixed |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public function getNew($command_fqcn, $arguments = array()) |
|
50 | - { |
|
51 | - return $this->loader->getNew($command_fqcn, $arguments); |
|
52 | - } |
|
21 | + /** |
|
22 | + * @var LoaderInterface $loader |
|
23 | + */ |
|
24 | + private $loader; |
|
25 | + |
|
26 | + |
|
27 | + /** |
|
28 | + * CommandFactory constructor |
|
29 | + * |
|
30 | + * @param LoaderInterface $loader |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + * @throws InvalidInterfaceException |
|
33 | + * @throws InvalidArgumentException |
|
34 | + */ |
|
35 | + public function __construct(LoaderInterface $loader = null) |
|
36 | + { |
|
37 | + $this->loader = $loader; |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * @param string $command_fqcn |
|
43 | + * @param array $arguments |
|
44 | + * @return mixed |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public function getNew($command_fqcn, $arguments = array()) |
|
50 | + { |
|
51 | + return $this->loader->getNew($command_fqcn, $arguments); |
|
52 | + } |
|
53 | 53 | } |
@@ -17,26 +17,26 @@ |
||
17 | 17 | abstract class Command implements CommandInterface |
18 | 18 | { |
19 | 19 | |
20 | - /* |
|
20 | + /* |
|
21 | 21 | * @var CapCheckInterface $cap_check |
22 | 22 | */ |
23 | - protected $cap_check; |
|
23 | + protected $cap_check; |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * @return mixed |
|
28 | - */ |
|
29 | - public function getCapCheck() |
|
30 | - { |
|
31 | - return $this->cap_check; |
|
32 | - } |
|
26 | + /** |
|
27 | + * @return mixed |
|
28 | + */ |
|
29 | + public function getCapCheck() |
|
30 | + { |
|
31 | + return $this->cap_check; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @param CapCheckInterface $cap_check |
|
37 | - */ |
|
38 | - public function setCapCheck(CapCheckInterface $cap_check) |
|
39 | - { |
|
40 | - $this->cap_check = $cap_check; |
|
41 | - } |
|
35 | + /** |
|
36 | + * @param CapCheckInterface $cap_check |
|
37 | + */ |
|
38 | + public function setCapCheck(CapCheckInterface $cap_check) |
|
39 | + { |
|
40 | + $this->cap_check = $cap_check; |
|
41 | + } |
|
42 | 42 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | class InvalidCommandHandlerException extends \DomainException |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @access public |
|
18 | - * @param string $command_name |
|
19 | - * @param string $message |
|
20 | - * @param int $code |
|
21 | - * @param \Exception $previous |
|
22 | - */ |
|
23 | - public function __construct($command_name, $message = '', $code = 0, \Exception $previous = null) |
|
24 | - { |
|
25 | - if (empty($message)) { |
|
26 | - $message = sprintf( |
|
27 | - __( |
|
28 | - 'The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - $command_name |
|
32 | - ); |
|
33 | - } |
|
34 | - parent::__construct($message, $code, $previous); |
|
35 | - } |
|
16 | + /** |
|
17 | + * @access public |
|
18 | + * @param string $command_name |
|
19 | + * @param string $message |
|
20 | + * @param int $code |
|
21 | + * @param \Exception $previous |
|
22 | + */ |
|
23 | + public function __construct($command_name, $message = '', $code = 0, \Exception $previous = null) |
|
24 | + { |
|
25 | + if (empty($message)) { |
|
26 | + $message = sprintf( |
|
27 | + __( |
|
28 | + 'The supplied Command Handler "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + $command_name |
|
32 | + ); |
|
33 | + } |
|
34 | + parent::__construct($message, $code, $previous); |
|
35 | + } |
|
36 | 36 | } |
@@ -15,53 +15,53 @@ |
||
15 | 15 | abstract class CompositeCommandHandler extends CommandHandler |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @type CommandBusInterface $command_bus |
|
20 | - */ |
|
21 | - private $command_bus; |
|
18 | + /** |
|
19 | + * @type CommandBusInterface $command_bus |
|
20 | + */ |
|
21 | + private $command_bus; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @type CommandFactoryInterface $command_factory |
|
25 | - */ |
|
26 | - private $command_factory; |
|
23 | + /** |
|
24 | + * @type CommandFactoryInterface $command_factory |
|
25 | + */ |
|
26 | + private $command_factory; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * CompositeCommandHandler constructor. |
|
31 | - * |
|
32 | - * @param CommandBusInterface $command_bus |
|
33 | - * @param CommandFactoryInterface $command_factory |
|
34 | - */ |
|
35 | - public function __construct(CommandBusInterface $command_bus, CommandFactoryInterface $command_factory) |
|
36 | - { |
|
37 | - $this->command_bus = $command_bus; |
|
38 | - $this->command_factory = $command_factory; |
|
39 | - } |
|
29 | + /** |
|
30 | + * CompositeCommandHandler constructor. |
|
31 | + * |
|
32 | + * @param CommandBusInterface $command_bus |
|
33 | + * @param CommandFactoryInterface $command_factory |
|
34 | + */ |
|
35 | + public function __construct(CommandBusInterface $command_bus, CommandFactoryInterface $command_factory) |
|
36 | + { |
|
37 | + $this->command_bus = $command_bus; |
|
38 | + $this->command_factory = $command_factory; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | |
42 | - /** |
|
43 | - * @param CommandBusInterface $command_bus |
|
44 | - */ |
|
45 | - public function setCommandBus(CommandBusInterface $command_bus) |
|
46 | - { |
|
47 | - $this->command_bus = $command_bus; |
|
48 | - } |
|
42 | + /** |
|
43 | + * @param CommandBusInterface $command_bus |
|
44 | + */ |
|
45 | + public function setCommandBus(CommandBusInterface $command_bus) |
|
46 | + { |
|
47 | + $this->command_bus = $command_bus; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return CommandBusInterface |
|
53 | - */ |
|
54 | - public function commandBus() |
|
55 | - { |
|
56 | - return $this->command_bus; |
|
57 | - } |
|
51 | + /** |
|
52 | + * @return CommandBusInterface |
|
53 | + */ |
|
54 | + public function commandBus() |
|
55 | + { |
|
56 | + return $this->command_bus; |
|
57 | + } |
|
58 | 58 | |
59 | 59 | |
60 | - /** |
|
61 | - * @return CommandFactoryInterface |
|
62 | - */ |
|
63 | - public function commandFactory() |
|
64 | - { |
|
65 | - return $this->command_factory; |
|
66 | - } |
|
60 | + /** |
|
61 | + * @return CommandFactoryInterface |
|
62 | + */ |
|
63 | + public function commandFactory() |
|
64 | + { |
|
65 | + return $this->command_factory; |
|
66 | + } |
|
67 | 67 | } |
@@ -13,21 +13,21 @@ |
||
13 | 13 | class CommandHandlerNotFoundException extends \OutOfBoundsException |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @access public |
|
18 | - * @param string $command_handler_name |
|
19 | - * @param string $message |
|
20 | - * @param int $code |
|
21 | - * @param \Exception $previous |
|
22 | - */ |
|
23 | - public function __construct($command_handler_name, $message = '', $code = 0, \Exception $previous = null) |
|
24 | - { |
|
25 | - if (empty($message)) { |
|
26 | - $message = sprintf( |
|
27 | - __('The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso'), |
|
28 | - $command_handler_name |
|
29 | - ); |
|
30 | - } |
|
31 | - parent::__construct($message, $code, $previous); |
|
32 | - } |
|
16 | + /** |
|
17 | + * @access public |
|
18 | + * @param string $command_handler_name |
|
19 | + * @param string $message |
|
20 | + * @param int $code |
|
21 | + * @param \Exception $previous |
|
22 | + */ |
|
23 | + public function __construct($command_handler_name, $message = '', $code = 0, \Exception $previous = null) |
|
24 | + { |
|
25 | + if (empty($message)) { |
|
26 | + $message = sprintf( |
|
27 | + __('The requested Command Handler "%1$s" could not be located or does not exist.', 'event_espresso'), |
|
28 | + $command_handler_name |
|
29 | + ); |
|
30 | + } |
|
31 | + parent::__construct($message, $code, $previous); |
|
32 | + } |
|
33 | 33 | } |