@@ -14,11 +14,11 @@ |
||
14 | 14 | */ |
15 | 15 | class WordPressHeartbeat extends RouteMatchSpecification |
16 | 16 | { |
17 | - /** |
|
18 | - * @inheritDoc |
|
19 | - */ |
|
20 | - public function isMatchingRoute() |
|
21 | - { |
|
22 | - return $this->request->isWordPressHeartbeat(); |
|
23 | - } |
|
17 | + /** |
|
18 | + * @inheritDoc |
|
19 | + */ |
|
20 | + public function isMatchingRoute() |
|
21 | + { |
|
22 | + return $this->request->isWordPressHeartbeat(); |
|
23 | + } |
|
24 | 24 | } |
@@ -21,176 +21,176 @@ |
||
21 | 21 | class EventAttendees extends Block |
22 | 22 | { |
23 | 23 | |
24 | - const BLOCK_TYPE = 'event-attendees'; |
|
24 | + const BLOCK_TYPE = 'event-attendees'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var EventAttendeesBlockRenderer $renderer |
|
28 | - */ |
|
29 | - protected $renderer; |
|
26 | + /** |
|
27 | + * @var EventAttendeesBlockRenderer $renderer |
|
28 | + */ |
|
29 | + protected $renderer; |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * EventAttendees constructor. |
|
34 | - * |
|
35 | - * @param CoreBlocksAssetManager $block_asset_manager |
|
36 | - * @param RequestInterface $request |
|
37 | - * @param EventAttendeesBlockRenderer $renderer |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - CoreBlocksAssetManager $block_asset_manager, |
|
41 | - RequestInterface $request, |
|
42 | - EventAttendeesBlockRenderer $renderer |
|
43 | - ) { |
|
44 | - parent::__construct($block_asset_manager, $request); |
|
45 | - $this->renderer= $renderer; |
|
46 | - } |
|
32 | + /** |
|
33 | + * EventAttendees constructor. |
|
34 | + * |
|
35 | + * @param CoreBlocksAssetManager $block_asset_manager |
|
36 | + * @param RequestInterface $request |
|
37 | + * @param EventAttendeesBlockRenderer $renderer |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + CoreBlocksAssetManager $block_asset_manager, |
|
41 | + RequestInterface $request, |
|
42 | + EventAttendeesBlockRenderer $renderer |
|
43 | + ) { |
|
44 | + parent::__construct($block_asset_manager, $request); |
|
45 | + $this->renderer= $renderer; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Perform any early setup required by the block |
|
51 | - * including setting the block type and supported post types |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initialize() |
|
56 | - { |
|
57 | - $this->setBlockType(EventAttendees::BLOCK_TYPE); |
|
58 | - $this->setSupportedRoutes( |
|
59 | - array( |
|
60 | - 'EventEspresso\core\domain\entities\routes\specifications\admin\WordPressPostTypeEditor', |
|
61 | - 'EventEspresso\core\domain\entities\routes\specifications\frontend\EspressoBlockRenderer', |
|
62 | - 'EventEspresso\core\domain\entities\routes\specifications\frontend\AnyFrontendRequest' |
|
63 | - ) |
|
64 | - ); |
|
65 | - $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
66 | - ? $this->request->getRequestParam('post', 0) |
|
67 | - : 0; |
|
68 | - $this->setAttributes( |
|
69 | - array( |
|
70 | - 'eventId' => array( |
|
71 | - 'type' => 'number', |
|
72 | - 'default' => $EVT_ID, |
|
73 | - ), |
|
74 | - 'datetimeId' => array( |
|
75 | - 'type' => 'number', |
|
76 | - 'default' => 0, |
|
77 | - ), |
|
78 | - 'ticketId' => array( |
|
79 | - 'type' => 'number', |
|
80 | - 'default' => 0, |
|
81 | - ), |
|
82 | - 'status' => array( |
|
83 | - 'type' => 'string', |
|
84 | - 'default' => EEM_Registration::status_id_approved, |
|
85 | - ), |
|
86 | - 'limit' => array( |
|
87 | - 'type' => 'number', |
|
88 | - 'default' => 100, |
|
89 | - ), |
|
90 | - 'order' => array( |
|
91 | - 'type' => 'string', |
|
92 | - 'default' => 'ASC' |
|
93 | - ), |
|
94 | - 'orderBy' => array( |
|
95 | - 'type' => 'string', |
|
96 | - 'default' => 'lastThenFirstName', |
|
97 | - ), |
|
98 | - 'showGravatar' => array( |
|
99 | - 'type' => 'boolean', |
|
100 | - 'default' => false, |
|
101 | - ), |
|
102 | - 'avatarClass' => array( |
|
103 | - 'type' => 'string', |
|
104 | - 'default' => 'contact', |
|
105 | - ), |
|
106 | - 'avatarSize' => array( |
|
107 | - 'type' => 'number', |
|
108 | - 'default' => 24, |
|
109 | - ), |
|
110 | - 'displayOnArchives' => array( |
|
111 | - 'type' => 'boolean', |
|
112 | - 'default' => false, |
|
113 | - ), |
|
114 | - ) |
|
115 | - ); |
|
116 | - $this->setDynamic(); |
|
117 | - } |
|
49 | + /** |
|
50 | + * Perform any early setup required by the block |
|
51 | + * including setting the block type and supported post types |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initialize() |
|
56 | + { |
|
57 | + $this->setBlockType(EventAttendees::BLOCK_TYPE); |
|
58 | + $this->setSupportedRoutes( |
|
59 | + array( |
|
60 | + 'EventEspresso\core\domain\entities\routes\specifications\admin\WordPressPostTypeEditor', |
|
61 | + 'EventEspresso\core\domain\entities\routes\specifications\frontend\EspressoBlockRenderer', |
|
62 | + 'EventEspresso\core\domain\entities\routes\specifications\frontend\AnyFrontendRequest' |
|
63 | + ) |
|
64 | + ); |
|
65 | + $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
66 | + ? $this->request->getRequestParam('post', 0) |
|
67 | + : 0; |
|
68 | + $this->setAttributes( |
|
69 | + array( |
|
70 | + 'eventId' => array( |
|
71 | + 'type' => 'number', |
|
72 | + 'default' => $EVT_ID, |
|
73 | + ), |
|
74 | + 'datetimeId' => array( |
|
75 | + 'type' => 'number', |
|
76 | + 'default' => 0, |
|
77 | + ), |
|
78 | + 'ticketId' => array( |
|
79 | + 'type' => 'number', |
|
80 | + 'default' => 0, |
|
81 | + ), |
|
82 | + 'status' => array( |
|
83 | + 'type' => 'string', |
|
84 | + 'default' => EEM_Registration::status_id_approved, |
|
85 | + ), |
|
86 | + 'limit' => array( |
|
87 | + 'type' => 'number', |
|
88 | + 'default' => 100, |
|
89 | + ), |
|
90 | + 'order' => array( |
|
91 | + 'type' => 'string', |
|
92 | + 'default' => 'ASC' |
|
93 | + ), |
|
94 | + 'orderBy' => array( |
|
95 | + 'type' => 'string', |
|
96 | + 'default' => 'lastThenFirstName', |
|
97 | + ), |
|
98 | + 'showGravatar' => array( |
|
99 | + 'type' => 'boolean', |
|
100 | + 'default' => false, |
|
101 | + ), |
|
102 | + 'avatarClass' => array( |
|
103 | + 'type' => 'string', |
|
104 | + 'default' => 'contact', |
|
105 | + ), |
|
106 | + 'avatarSize' => array( |
|
107 | + 'type' => 'number', |
|
108 | + 'default' => 24, |
|
109 | + ), |
|
110 | + 'displayOnArchives' => array( |
|
111 | + 'type' => 'boolean', |
|
112 | + 'default' => false, |
|
113 | + ), |
|
114 | + ) |
|
115 | + ); |
|
116 | + $this->setDynamic(); |
|
117 | + } |
|
118 | 118 | |
119 | 119 | |
120 | - /** |
|
121 | - * Returns an array where the key corresponds to the incoming attribute name from the WP block |
|
122 | - * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
123 | - * |
|
124 | - * @since 4.9.71.p |
|
125 | - * @return array |
|
126 | - */ |
|
127 | - private function getAttributesMap() |
|
128 | - { |
|
129 | - return array( |
|
130 | - 'event' => 'sanitize_text_field', |
|
131 | - 'datetime' => 'sanitize_text_field', |
|
132 | - 'ticket' => 'sanitize_text_field', |
|
133 | - 'eventId' => 'absint', |
|
134 | - 'datetimeId' => 'absint', |
|
135 | - 'ticketId' => 'absint', |
|
136 | - 'status' => 'sanitize_text_field', |
|
137 | - 'limit' => 'intval', |
|
138 | - 'showGravatar' => 'bool', |
|
139 | - 'avatarClass' => 'sanitize_text_field', |
|
140 | - 'avatarSize' => 'absint', |
|
141 | - 'displayOnArchives' => 'bool', |
|
142 | - 'order' => 'sanitize_text_field', |
|
143 | - 'orderBy' => 'sanitize_text_field', |
|
144 | - ); |
|
145 | - } |
|
120 | + /** |
|
121 | + * Returns an array where the key corresponds to the incoming attribute name from the WP block |
|
122 | + * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
123 | + * |
|
124 | + * @since 4.9.71.p |
|
125 | + * @return array |
|
126 | + */ |
|
127 | + private function getAttributesMap() |
|
128 | + { |
|
129 | + return array( |
|
130 | + 'event' => 'sanitize_text_field', |
|
131 | + 'datetime' => 'sanitize_text_field', |
|
132 | + 'ticket' => 'sanitize_text_field', |
|
133 | + 'eventId' => 'absint', |
|
134 | + 'datetimeId' => 'absint', |
|
135 | + 'ticketId' => 'absint', |
|
136 | + 'status' => 'sanitize_text_field', |
|
137 | + 'limit' => 'intval', |
|
138 | + 'showGravatar' => 'bool', |
|
139 | + 'avatarClass' => 'sanitize_text_field', |
|
140 | + 'avatarSize' => 'absint', |
|
141 | + 'displayOnArchives' => 'bool', |
|
142 | + 'order' => 'sanitize_text_field', |
|
143 | + 'orderBy' => 'sanitize_text_field', |
|
144 | + ); |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | - /** |
|
149 | - * Sanitizes attributes. |
|
150 | - * |
|
151 | - * @param array $attributes |
|
152 | - * @return array |
|
153 | - */ |
|
154 | - private function sanitizeAttributes(array $attributes) |
|
155 | - { |
|
156 | - $sanitized_attributes = array(); |
|
157 | - foreach ($attributes as $attribute => $value) { |
|
158 | - $convert = $this->getAttributesMap(); |
|
159 | - if (isset($convert[ $attribute ])) { |
|
160 | - $sanitize = $convert[ $attribute ]; |
|
161 | - if ($sanitize === 'bool') { |
|
162 | - $sanitized_attributes[ $attribute ] = filter_var( |
|
163 | - $value, |
|
164 | - FILTER_VALIDATE_BOOLEAN |
|
165 | - ); |
|
166 | - } else { |
|
167 | - $sanitized_attributes[ $attribute ] = $sanitize($value); |
|
168 | - } |
|
169 | - // don't pass along attributes with a 0 value |
|
170 | - if ($sanitized_attributes[ $attribute ] === 0) { |
|
171 | - unset($sanitized_attributes[ $attribute ]); |
|
172 | - } |
|
173 | - } |
|
174 | - } |
|
175 | - return $attributes; |
|
176 | - } |
|
148 | + /** |
|
149 | + * Sanitizes attributes. |
|
150 | + * |
|
151 | + * @param array $attributes |
|
152 | + * @return array |
|
153 | + */ |
|
154 | + private function sanitizeAttributes(array $attributes) |
|
155 | + { |
|
156 | + $sanitized_attributes = array(); |
|
157 | + foreach ($attributes as $attribute => $value) { |
|
158 | + $convert = $this->getAttributesMap(); |
|
159 | + if (isset($convert[ $attribute ])) { |
|
160 | + $sanitize = $convert[ $attribute ]; |
|
161 | + if ($sanitize === 'bool') { |
|
162 | + $sanitized_attributes[ $attribute ] = filter_var( |
|
163 | + $value, |
|
164 | + FILTER_VALIDATE_BOOLEAN |
|
165 | + ); |
|
166 | + } else { |
|
167 | + $sanitized_attributes[ $attribute ] = $sanitize($value); |
|
168 | + } |
|
169 | + // don't pass along attributes with a 0 value |
|
170 | + if ($sanitized_attributes[ $attribute ] === 0) { |
|
171 | + unset($sanitized_attributes[ $attribute ]); |
|
172 | + } |
|
173 | + } |
|
174 | + } |
|
175 | + return $attributes; |
|
176 | + } |
|
177 | 177 | |
178 | 178 | |
179 | - /** |
|
180 | - * Returns the rendered HTML for the block |
|
181 | - * |
|
182 | - * @param array $attributes |
|
183 | - * @return string |
|
184 | - * @throws DomainException |
|
185 | - * @throws EE_Error |
|
186 | - */ |
|
187 | - public function renderBlock(array $attributes = array()) |
|
188 | - { |
|
189 | - $attributes = $this->sanitizeAttributes($attributes); |
|
190 | - if (! (bool) $attributes['displayOnArchives'] && (is_archive() || is_front_page() || is_home())) { |
|
191 | - return ''; |
|
192 | - } |
|
193 | - $this->loadGraphQLRelayAutoloader(); |
|
194 | - return $this->renderer->render($attributes); |
|
195 | - } |
|
179 | + /** |
|
180 | + * Returns the rendered HTML for the block |
|
181 | + * |
|
182 | + * @param array $attributes |
|
183 | + * @return string |
|
184 | + * @throws DomainException |
|
185 | + * @throws EE_Error |
|
186 | + */ |
|
187 | + public function renderBlock(array $attributes = array()) |
|
188 | + { |
|
189 | + $attributes = $this->sanitizeAttributes($attributes); |
|
190 | + if (! (bool) $attributes['displayOnArchives'] && (is_archive() || is_front_page() || is_home())) { |
|
191 | + return ''; |
|
192 | + } |
|
193 | + $this->loadGraphQLRelayAutoloader(); |
|
194 | + return $this->renderer->render($attributes); |
|
195 | + } |
|
196 | 196 | } |
@@ -11,99 +11,99 @@ |
||
11 | 11 | class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
16 | - * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
17 | - * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
18 | - * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button |
|
19 | - * to select media). |
|
20 | - * Besides that, no special consideration should be required to make the media uploader appear, besides having |
|
21 | - * this input displayed. |
|
22 | - * @deprecated. enqueue_js should be called automatically now |
|
23 | - */ |
|
24 | - public static function enqueue_scripts() |
|
25 | - { |
|
26 | - EE_Error::doing_it_wrong( |
|
27 | - __FUNCTION__, |
|
28 | - __( |
|
29 | - 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', |
|
30 | - 'event_espresso' |
|
31 | - ), |
|
32 | - '4.9.8.rc.015' |
|
33 | - ); |
|
34 | - wp_enqueue_media(); |
|
35 | - wp_enqueue_script('media-upload'); |
|
36 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
37 | - } |
|
14 | + /** |
|
15 | + * Its important this media only get enqueued AFTER init, but before the footer... where the |
|
16 | + * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine, |
|
17 | + * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error |
|
18 | + * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button |
|
19 | + * to select media). |
|
20 | + * Besides that, no special consideration should be required to make the media uploader appear, besides having |
|
21 | + * this input displayed. |
|
22 | + * @deprecated. enqueue_js should be called automatically now |
|
23 | + */ |
|
24 | + public static function enqueue_scripts() |
|
25 | + { |
|
26 | + EE_Error::doing_it_wrong( |
|
27 | + __FUNCTION__, |
|
28 | + __( |
|
29 | + 'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form', |
|
30 | + 'event_espresso' |
|
31 | + ), |
|
32 | + '4.9.8.rc.015' |
|
33 | + ); |
|
34 | + wp_enqueue_media(); |
|
35 | + wp_enqueue_script('media-upload'); |
|
36 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Enqueues the JS and CSS needed to display this input |
|
42 | - */ |
|
43 | - public function enqueue_js() |
|
44 | - { |
|
45 | - wp_enqueue_media(); |
|
46 | - wp_enqueue_script('media-upload'); |
|
47 | - wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
48 | - parent::enqueue_js(); |
|
49 | - } |
|
40 | + /** |
|
41 | + * Enqueues the JS and CSS needed to display this input |
|
42 | + */ |
|
43 | + public function enqueue_js() |
|
44 | + { |
|
45 | + wp_enqueue_media(); |
|
46 | + wp_enqueue_script('media-upload'); |
|
47 | + wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js'); |
|
48 | + parent::enqueue_js(); |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * |
|
55 | - * @return string of html to display the field |
|
56 | - */ |
|
53 | + /** |
|
54 | + * |
|
55 | + * @return string of html to display the field |
|
56 | + */ |
|
57 | 57 | |
58 | - public function display() |
|
59 | - { |
|
60 | - // the actual input |
|
61 | - $input = '<input type="text" size="34" '; |
|
62 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
63 | - $input .= $this->_input->html_class() !== '' |
|
64 | - ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
65 | - : 'class="large-text ee_media_url" '; |
|
66 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
67 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
68 | - // image uploader |
|
69 | - $uploader = EEH_HTML::link( |
|
70 | - '#', |
|
71 | - '<img src="' . admin_url('images/media-button-image.gif') . '" >', |
|
72 | - __('click to add an image', 'event_espresso'), |
|
73 | - '', |
|
74 | - 'ee_media_upload' |
|
75 | - ); |
|
76 | - // only attempt to show the image if it at least exists |
|
77 | - $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
|
78 | - ? EEH_HTML::br(2) . EEH_HTML::img( |
|
79 | - $this->_input->raw_value(), |
|
80 | - __('logo', 'event_espresso'), |
|
81 | - '', |
|
82 | - 'ee_media_image' |
|
83 | - ) |
|
84 | - : ''; |
|
85 | - // html string |
|
86 | - return EEH_HTML::div( |
|
87 | - $input . EEH_HTML::nbsp() . $uploader . $image, |
|
88 | - '', |
|
89 | - 'ee_media_uploader_area' |
|
90 | - ); |
|
91 | - } |
|
58 | + public function display() |
|
59 | + { |
|
60 | + // the actual input |
|
61 | + $input = '<input type="text" size="34" '; |
|
62 | + $input .= 'name="' . $this->_input->html_name() . '" '; |
|
63 | + $input .= $this->_input->html_class() !== '' |
|
64 | + ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
65 | + : 'class="large-text ee_media_url" '; |
|
66 | + $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
67 | + $input .= $this->_input->other_html_attributes() . '>'; |
|
68 | + // image uploader |
|
69 | + $uploader = EEH_HTML::link( |
|
70 | + '#', |
|
71 | + '<img src="' . admin_url('images/media-button-image.gif') . '" >', |
|
72 | + __('click to add an image', 'event_espresso'), |
|
73 | + '', |
|
74 | + 'ee_media_upload' |
|
75 | + ); |
|
76 | + // only attempt to show the image if it at least exists |
|
77 | + $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
|
78 | + ? EEH_HTML::br(2) . EEH_HTML::img( |
|
79 | + $this->_input->raw_value(), |
|
80 | + __('logo', 'event_espresso'), |
|
81 | + '', |
|
82 | + 'ee_media_image' |
|
83 | + ) |
|
84 | + : ''; |
|
85 | + // html string |
|
86 | + return EEH_HTML::div( |
|
87 | + $input . EEH_HTML::nbsp() . $uploader . $image, |
|
88 | + '', |
|
89 | + 'ee_media_uploader_area' |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
97 | - * request |
|
98 | - * @param string $src |
|
99 | - * @return boolean |
|
100 | - */ |
|
101 | - protected function src_exists($src) |
|
102 | - { |
|
103 | - $results = wp_remote_head($src); |
|
104 | - if (is_array($results) && ! $results instanceof WP_Error) { |
|
105 | - return strpos($results['headers']['content-type'], "image") !== false; |
|
106 | - } |
|
107 | - return false; |
|
108 | - } |
|
95 | + /** |
|
96 | + * Asserts an image actually exists as quickly as possible by sending a HEAD |
|
97 | + * request |
|
98 | + * @param string $src |
|
99 | + * @return boolean |
|
100 | + */ |
|
101 | + protected function src_exists($src) |
|
102 | + { |
|
103 | + $results = wp_remote_head($src); |
|
104 | + if (is_array($results) && ! $results instanceof WP_Error) { |
|
105 | + return strpos($results['headers']['content-type'], "image") !== false; |
|
106 | + } |
|
107 | + return false; |
|
108 | + } |
|
109 | 109 | } |
@@ -59,23 +59,23 @@ discard block |
||
59 | 59 | { |
60 | 60 | // the actual input |
61 | 61 | $input = '<input type="text" size="34" '; |
62 | - $input .= 'name="' . $this->_input->html_name() . '" '; |
|
62 | + $input .= 'name="'.$this->_input->html_name().'" '; |
|
63 | 63 | $input .= $this->_input->html_class() !== '' |
64 | - ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" ' |
|
64 | + ? 'class="large-text ee_media_url '.$this->_input->html_class().'" ' |
|
65 | 65 | : 'class="large-text ee_media_url" '; |
66 | - $input .= 'value="' . $this->_input->raw_value_in_form() . '" '; |
|
67 | - $input .= $this->_input->other_html_attributes() . '>'; |
|
66 | + $input .= 'value="'.$this->_input->raw_value_in_form().'" '; |
|
67 | + $input .= $this->_input->other_html_attributes().'>'; |
|
68 | 68 | // image uploader |
69 | 69 | $uploader = EEH_HTML::link( |
70 | 70 | '#', |
71 | - '<img src="' . admin_url('images/media-button-image.gif') . '" >', |
|
71 | + '<img src="'.admin_url('images/media-button-image.gif').'" >', |
|
72 | 72 | __('click to add an image', 'event_espresso'), |
73 | 73 | '', |
74 | 74 | 'ee_media_upload' |
75 | 75 | ); |
76 | 76 | // only attempt to show the image if it at least exists |
77 | 77 | $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value()) |
78 | - ? EEH_HTML::br(2) . EEH_HTML::img( |
|
78 | + ? EEH_HTML::br(2).EEH_HTML::img( |
|
79 | 79 | $this->_input->raw_value(), |
80 | 80 | __('logo', 'event_espresso'), |
81 | 81 | '', |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | : ''; |
85 | 85 | // html string |
86 | 86 | return EEH_HTML::div( |
87 | - $input . EEH_HTML::nbsp() . $uploader . $image, |
|
87 | + $input.EEH_HTML::nbsp().$uploader.$image, |
|
88 | 88 | '', |
89 | 89 | 'ee_media_uploader_area' |
90 | 90 | ); |
@@ -15,102 +15,102 @@ |
||
15 | 15 | abstract class DependencyMapRegistrar |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Dependency_Map $dependency_map |
|
20 | - */ |
|
21 | - protected $dependency_map; |
|
18 | + /** |
|
19 | + * @var EE_Dependency_Map $dependency_map |
|
20 | + */ |
|
21 | + protected $dependency_map; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var boolean $registered |
|
25 | - */ |
|
26 | - private $registered = false; |
|
23 | + /** |
|
24 | + * @var boolean $registered |
|
25 | + */ |
|
26 | + private $registered = false; |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * DependencyMap constructor. |
|
31 | - * |
|
32 | - * @param EE_Dependency_Map $dependency_map |
|
33 | - */ |
|
34 | - public function __construct(EE_Dependency_Map $dependency_map) |
|
35 | - { |
|
36 | - $this->dependency_map = $dependency_map; |
|
37 | - } |
|
29 | + /** |
|
30 | + * DependencyMap constructor. |
|
31 | + * |
|
32 | + * @param EE_Dependency_Map $dependency_map |
|
33 | + */ |
|
34 | + public function __construct(EE_Dependency_Map $dependency_map) |
|
35 | + { |
|
36 | + $this->dependency_map = $dependency_map; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * registers concrete classes to be substituted for interfaces |
|
42 | - * ex: |
|
43 | - * $this->dependency_map->add_alias( |
|
44 | - * 'Namespace\path\to\ConcreteClassToInject', // the class name the alias is for |
|
45 | - * 'Namespace\path\to\InterfaceOrAlias', // the class name that would be type hinted for |
|
46 | - * 'Namespace\path\to\ClassWithDependencies' // the class that has the dependency |
|
47 | - * ); |
|
48 | - * |
|
49 | - * @return void |
|
50 | - * @see EE_Dependency_Map::add_alias() |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function registerClassAliases() |
|
54 | - { |
|
55 | - } |
|
40 | + /** |
|
41 | + * registers concrete classes to be substituted for interfaces |
|
42 | + * ex: |
|
43 | + * $this->dependency_map->add_alias( |
|
44 | + * 'Namespace\path\to\ConcreteClassToInject', // the class name the alias is for |
|
45 | + * 'Namespace\path\to\InterfaceOrAlias', // the class name that would be type hinted for |
|
46 | + * 'Namespace\path\to\ClassWithDependencies' // the class that has the dependency |
|
47 | + * ); |
|
48 | + * |
|
49 | + * @return void |
|
50 | + * @see EE_Dependency_Map::add_alias() |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function registerClassAliases() |
|
54 | + { |
|
55 | + } |
|
56 | 56 | |
57 | 57 | |
58 | - /** |
|
59 | - * registers callbacks for classes that require special loading |
|
60 | - * ex: |
|
61 | - * $this->registerClassLoader( |
|
62 | - * 'Namespace\path\to\ConcreteClassToInject', // name of class that requires a custom loader |
|
63 | - * 'load_core' || static function () { ... } // name of "loader" method on EE_Registry or Closure |
|
64 | - * ); |
|
65 | - * |
|
66 | - * @return void |
|
67 | - * @see EE_Dependency_Map::register_class_loader() |
|
68 | - * @since $VID:$ |
|
69 | - */ |
|
70 | - public function registerClassLoaders() |
|
71 | - { |
|
72 | - } |
|
58 | + /** |
|
59 | + * registers callbacks for classes that require special loading |
|
60 | + * ex: |
|
61 | + * $this->registerClassLoader( |
|
62 | + * 'Namespace\path\to\ConcreteClassToInject', // name of class that requires a custom loader |
|
63 | + * 'load_core' || static function () { ... } // name of "loader" method on EE_Registry or Closure |
|
64 | + * ); |
|
65 | + * |
|
66 | + * @return void |
|
67 | + * @see EE_Dependency_Map::register_class_loader() |
|
68 | + * @since $VID:$ |
|
69 | + */ |
|
70 | + public function registerClassLoaders() |
|
71 | + { |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - /** |
|
76 | - * registers dependencies to be injected into a class upon construction |
|
77 | - * ex: |
|
78 | - * $this->registerDependencies($class, $dependencies, $overwrite); |
|
79 | - * 'Namespace\path\to\ConcreteClassToInject', // name of class that requires injected dependencies |
|
80 | - * [ |
|
81 | - * 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
82 | - * 'LoaderInterface' => EE_Dependency_Map::load_from_cache, |
|
83 | - * 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
84 | - * ], // array where keys are FQCNs and values are load sources (new or cached) |
|
85 | - * EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES || EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
86 | - * ); |
|
87 | - * IMPORTANT !!! |
|
88 | - * The order of elements in the incoming $dependencies array MUST match |
|
89 | - * the order of the constructor parameters for the class in question. |
|
90 | - * This is especially important when overriding any existing dependencies that are registered. |
|
91 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
92 | - * |
|
93 | - * @return bool |
|
94 | - * @see EE_Dependency_Map::registerDependencies() |
|
95 | - * @since $VID:$ |
|
96 | - */ |
|
97 | - public function registerDependencies() |
|
98 | - { |
|
99 | - return false; |
|
100 | - } |
|
75 | + /** |
|
76 | + * registers dependencies to be injected into a class upon construction |
|
77 | + * ex: |
|
78 | + * $this->registerDependencies($class, $dependencies, $overwrite); |
|
79 | + * 'Namespace\path\to\ConcreteClassToInject', // name of class that requires injected dependencies |
|
80 | + * [ |
|
81 | + * 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
82 | + * 'LoaderInterface' => EE_Dependency_Map::load_from_cache, |
|
83 | + * 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
84 | + * ], // array where keys are FQCNs and values are load sources (new or cached) |
|
85 | + * EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES || EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
86 | + * ); |
|
87 | + * IMPORTANT !!! |
|
88 | + * The order of elements in the incoming $dependencies array MUST match |
|
89 | + * the order of the constructor parameters for the class in question. |
|
90 | + * This is especially important when overriding any existing dependencies that are registered. |
|
91 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
92 | + * |
|
93 | + * @return bool |
|
94 | + * @see EE_Dependency_Map::registerDependencies() |
|
95 | + * @since $VID:$ |
|
96 | + */ |
|
97 | + public function registerDependencies() |
|
98 | + { |
|
99 | + return false; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * @since $VID:$ |
|
105 | - */ |
|
106 | - public function register() |
|
107 | - { |
|
108 | - if ($this->registered) { |
|
109 | - return; |
|
110 | - } |
|
111 | - // \EEH_Debug_Tools::printr(get_called_class(), __FUNCTION__, __FILE__, __LINE__); |
|
112 | - $this->registerClassAliases(); |
|
113 | - $this->registerClassLoaders(); |
|
114 | - $this->registered = $this->registerDependencies(); |
|
115 | - } |
|
103 | + /** |
|
104 | + * @since $VID:$ |
|
105 | + */ |
|
106 | + public function register() |
|
107 | + { |
|
108 | + if ($this->registered) { |
|
109 | + return; |
|
110 | + } |
|
111 | + // \EEH_Debug_Tools::printr(get_called_class(), __FUNCTION__, __FILE__, __LINE__); |
|
112 | + $this->registerClassAliases(); |
|
113 | + $this->registerClassLoaders(); |
|
114 | + $this->registered = $this->registerDependencies(); |
|
115 | + } |
|
116 | 116 | } |
@@ -23,42 +23,42 @@ |
||
23 | 23 | class LocalDependencyMapFactory extends FactoryWithDependencyResolver |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * RouteFactory constructor |
|
28 | - * |
|
29 | - * @param DependencyResolver $dependency_resolver |
|
30 | - * @param LoaderInterface $loader |
|
31 | - */ |
|
32 | - public function __construct(DependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
33 | - { |
|
34 | - parent::__construct($dependency_resolver, $loader); |
|
35 | - } |
|
26 | + /** |
|
27 | + * RouteFactory constructor |
|
28 | + * |
|
29 | + * @param DependencyResolver $dependency_resolver |
|
30 | + * @param LoaderInterface $loader |
|
31 | + */ |
|
32 | + public function __construct(DependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
33 | + { |
|
34 | + parent::__construct($dependency_resolver, $loader); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @param $fqcn |
|
40 | - * @return Route |
|
41 | - * @since 4.9.71.p |
|
42 | - */ |
|
43 | - public function createRoute($fqcn) |
|
44 | - { |
|
45 | - $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
46 | - return $this->loader()->getShared($fqcn); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @param $fqcn |
|
40 | + * @return Route |
|
41 | + * @since 4.9.71.p |
|
42 | + */ |
|
43 | + public function createRoute($fqcn) |
|
44 | + { |
|
45 | + $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
46 | + return $this->loader()->getShared($fqcn); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $fqcn |
|
52 | - * @return Route |
|
53 | - * @throws InvalidArgumentException |
|
54 | - * @throws InvalidDataTypeException |
|
55 | - * @throws InvalidInterfaceException |
|
56 | - * @since 4.9.71.p |
|
57 | - */ |
|
58 | - public static function create($fqcn) |
|
59 | - { |
|
60 | - /** @var LocalDependencyMapFactory $local_dependency_map_factory */ |
|
61 | - $local_dependency_map_factory = LoaderFactory::getLoader()->getShared(LocalDependencyMapFactory::class); |
|
62 | - return $local_dependency_map_factory->createRoute($fqcn); |
|
63 | - } |
|
50 | + /** |
|
51 | + * @param $fqcn |
|
52 | + * @return Route |
|
53 | + * @throws InvalidArgumentException |
|
54 | + * @throws InvalidDataTypeException |
|
55 | + * @throws InvalidInterfaceException |
|
56 | + * @since 4.9.71.p |
|
57 | + */ |
|
58 | + public static function create($fqcn) |
|
59 | + { |
|
60 | + /** @var LocalDependencyMapFactory $local_dependency_map_factory */ |
|
61 | + $local_dependency_map_factory = LoaderFactory::getLoader()->getShared(LocalDependencyMapFactory::class); |
|
62 | + return $local_dependency_map_factory->createRoute($fqcn); |
|
63 | + } |
|
64 | 64 | } |
@@ -23,168 +23,168 @@ |
||
23 | 23 | class DependencyResolver implements DependencyResolverInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var Mirror $mirror |
|
28 | - */ |
|
29 | - private $mirror; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var ClassInterfaceCache $class_cache |
|
33 | - */ |
|
34 | - private $class_cache; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var EE_Dependency_Map $dependency_map |
|
38 | - */ |
|
39 | - private $dependency_map; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var ClassAlias[] $aliases |
|
43 | - */ |
|
44 | - protected $aliases = array(); |
|
45 | - |
|
46 | - /** |
|
47 | - * @var array $namespace_roots |
|
48 | - */ |
|
49 | - protected $namespace_roots = array(); |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | - * |
|
55 | - * @param Mirror $mirror |
|
56 | - * @param ClassInterfaceCache $class_cache |
|
57 | - * @param EE_Dependency_Map $dependency_map |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - Mirror $mirror, |
|
61 | - ClassInterfaceCache $class_cache, |
|
62 | - EE_Dependency_Map $dependency_map |
|
63 | - ) { |
|
64 | - $this->mirror = $mirror; |
|
65 | - $this->class_cache = $class_cache; |
|
66 | - $this->dependency_map = $dependency_map; |
|
67 | - $this->initialize(); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
73 | - * |
|
74 | - * @throws InvalidAliasException |
|
75 | - * @since 4.9.71.p |
|
76 | - */ |
|
77 | - public function initialize() |
|
78 | - { |
|
79 | - // nothing to do here for default resolver |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return Mirror |
|
85 | - */ |
|
86 | - public function mirror() |
|
87 | - { |
|
88 | - return $this->mirror; |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @return ClassInterfaceCache |
|
93 | - */ |
|
94 | - public function classCache() |
|
95 | - { |
|
96 | - return $this->class_cache; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @return EE_Dependency_Map |
|
101 | - */ |
|
102 | - public function dependencyMap() |
|
103 | - { |
|
104 | - return $this->dependency_map; |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
109 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
110 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
111 | - * @throws InvalidAliasException |
|
112 | - */ |
|
113 | - public function addAlias($fqcn, $alias, $for_class = '') |
|
114 | - { |
|
115 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
120 | - * @return string |
|
121 | - */ |
|
122 | - public function resolveAlias($param_fqcn) |
|
123 | - { |
|
124 | - return $this->class_cache->getFqnForAlias($param_fqcn); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Primarily used to indicate the namespace root for composite objects |
|
129 | - * so that dependencies requiring the same DependencyResolver can be acquired |
|
130 | - * for example: |
|
131 | - * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
132 | - * may all implement Vendor\path\to\Interface, |
|
133 | - * but Vendor\path\to\class\C could be a composite object |
|
134 | - * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
135 | - * and needs both of those dependencies resolved, which would therefore require |
|
136 | - * the use of the same DependencyResolver. |
|
137 | - * |
|
138 | - * By specifying a namespace root of "Vendor\path\to\", |
|
139 | - * then all classes that are descendants of that namespace |
|
140 | - * will use DependencyResolver to acquire the classes they need |
|
141 | - * |
|
142 | - * @param string $namespace_root Partial namespace used for detecting other classes |
|
143 | - * that should employ this same DependencyResolver |
|
144 | - */ |
|
145 | - public function addNamespaceRoot($namespace_root) |
|
146 | - { |
|
147 | - $this->namespace_roots[] = $namespace_root; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Returns true if the parameter FQCN belongs to one of |
|
152 | - * the namespaces that utilizes this DependencyResolver |
|
153 | - * |
|
154 | - * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
155 | - * @return boolean |
|
156 | - * @since 4.9.71.p |
|
157 | - */ |
|
158 | - public function dependencyRecursionExists($param_fqcn) |
|
159 | - { |
|
160 | - foreach ($this->namespace_roots as $namespace_root) { |
|
161 | - if (strpos($param_fqcn, $namespace_root) !== false) { |
|
162 | - return true; |
|
163 | - } |
|
164 | - } |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * @param string $fqcn Fully Qualified Class Name |
|
171 | - * @throws InvalidDataTypeException |
|
172 | - * @throws ReflectionException |
|
173 | - * @since 4.9.71.p |
|
174 | - */ |
|
175 | - public function resolveDependenciesForClass($fqcn) |
|
176 | - { |
|
177 | - $dependencies = array(); |
|
178 | - $params = $this->mirror()->getParameters($fqcn); |
|
179 | - foreach ($params as $index => $param) { |
|
180 | - // is this a dependency for a specific class ? |
|
181 | - $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
182 | - if ($this->dependencyRecursionExists($param_class)) { |
|
183 | - $this->resolveDependenciesForClass($param_class); |
|
184 | - } |
|
185 | - $param_class = $this->resolveAlias($param_class); |
|
186 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
187 | - } |
|
188 | - $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
189 | - } |
|
26 | + /** |
|
27 | + * @var Mirror $mirror |
|
28 | + */ |
|
29 | + private $mirror; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var ClassInterfaceCache $class_cache |
|
33 | + */ |
|
34 | + private $class_cache; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var EE_Dependency_Map $dependency_map |
|
38 | + */ |
|
39 | + private $dependency_map; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var ClassAlias[] $aliases |
|
43 | + */ |
|
44 | + protected $aliases = array(); |
|
45 | + |
|
46 | + /** |
|
47 | + * @var array $namespace_roots |
|
48 | + */ |
|
49 | + protected $namespace_roots = array(); |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * RouteMatchSpecificationDependencyResolver constructor. |
|
54 | + * |
|
55 | + * @param Mirror $mirror |
|
56 | + * @param ClassInterfaceCache $class_cache |
|
57 | + * @param EE_Dependency_Map $dependency_map |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + Mirror $mirror, |
|
61 | + ClassInterfaceCache $class_cache, |
|
62 | + EE_Dependency_Map $dependency_map |
|
63 | + ) { |
|
64 | + $this->mirror = $mirror; |
|
65 | + $this->class_cache = $class_cache; |
|
66 | + $this->dependency_map = $dependency_map; |
|
67 | + $this->initialize(); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Used to configure and/or setup any aliases or namespace roots required by the DependencyResolver |
|
73 | + * |
|
74 | + * @throws InvalidAliasException |
|
75 | + * @since 4.9.71.p |
|
76 | + */ |
|
77 | + public function initialize() |
|
78 | + { |
|
79 | + // nothing to do here for default resolver |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return Mirror |
|
85 | + */ |
|
86 | + public function mirror() |
|
87 | + { |
|
88 | + return $this->mirror; |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @return ClassInterfaceCache |
|
93 | + */ |
|
94 | + public function classCache() |
|
95 | + { |
|
96 | + return $this->class_cache; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @return EE_Dependency_Map |
|
101 | + */ |
|
102 | + public function dependencyMap() |
|
103 | + { |
|
104 | + return $this->dependency_map; |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
109 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
110 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
111 | + * @throws InvalidAliasException |
|
112 | + */ |
|
113 | + public function addAlias($fqcn, $alias, $for_class = '') |
|
114 | + { |
|
115 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
120 | + * @return string |
|
121 | + */ |
|
122 | + public function resolveAlias($param_fqcn) |
|
123 | + { |
|
124 | + return $this->class_cache->getFqnForAlias($param_fqcn); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Primarily used to indicate the namespace root for composite objects |
|
129 | + * so that dependencies requiring the same DependencyResolver can be acquired |
|
130 | + * for example: |
|
131 | + * Vendor\path\to\class\A, Vendor\path\to\class\B, and Vendor\path\to\class\C |
|
132 | + * may all implement Vendor\path\to\Interface, |
|
133 | + * but Vendor\path\to\class\C could be a composite object |
|
134 | + * that requires Vendor\path\to\class\A and Vendor\path\to\class\B, |
|
135 | + * and needs both of those dependencies resolved, which would therefore require |
|
136 | + * the use of the same DependencyResolver. |
|
137 | + * |
|
138 | + * By specifying a namespace root of "Vendor\path\to\", |
|
139 | + * then all classes that are descendants of that namespace |
|
140 | + * will use DependencyResolver to acquire the classes they need |
|
141 | + * |
|
142 | + * @param string $namespace_root Partial namespace used for detecting other classes |
|
143 | + * that should employ this same DependencyResolver |
|
144 | + */ |
|
145 | + public function addNamespaceRoot($namespace_root) |
|
146 | + { |
|
147 | + $this->namespace_roots[] = $namespace_root; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Returns true if the parameter FQCN belongs to one of |
|
152 | + * the namespaces that utilizes this DependencyResolver |
|
153 | + * |
|
154 | + * @param string $param_fqcn Fully Qualified Class Name for dependency parameter |
|
155 | + * @return boolean |
|
156 | + * @since 4.9.71.p |
|
157 | + */ |
|
158 | + public function dependencyRecursionExists($param_fqcn) |
|
159 | + { |
|
160 | + foreach ($this->namespace_roots as $namespace_root) { |
|
161 | + if (strpos($param_fqcn, $namespace_root) !== false) { |
|
162 | + return true; |
|
163 | + } |
|
164 | + } |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * @param string $fqcn Fully Qualified Class Name |
|
171 | + * @throws InvalidDataTypeException |
|
172 | + * @throws ReflectionException |
|
173 | + * @since 4.9.71.p |
|
174 | + */ |
|
175 | + public function resolveDependenciesForClass($fqcn) |
|
176 | + { |
|
177 | + $dependencies = array(); |
|
178 | + $params = $this->mirror()->getParameters($fqcn); |
|
179 | + foreach ($params as $index => $param) { |
|
180 | + // is this a dependency for a specific class ? |
|
181 | + $param_class = $this->mirror()->getParameterClassName($param, $fqcn, $index); |
|
182 | + if ($this->dependencyRecursionExists($param_class)) { |
|
183 | + $this->resolveDependenciesForClass($param_class); |
|
184 | + } |
|
185 | + $param_class = $this->resolveAlias($param_class); |
|
186 | + $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
187 | + } |
|
188 | + $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
|
189 | + } |
|
190 | 190 | } |
@@ -183,7 +183,7 @@ |
||
183 | 183 | $this->resolveDependenciesForClass($param_class); |
184 | 184 | } |
185 | 185 | $param_class = $this->resolveAlias($param_class); |
186 | - $dependencies[ $param_class ] = EE_Dependency_Map::load_from_cache; |
|
186 | + $dependencies[$param_class] = EE_Dependency_Map::load_from_cache; |
|
187 | 187 | } |
188 | 188 | $this->dependencyMap()->registerDependencies($fqcn, $dependencies); |
189 | 189 | } |
@@ -23,44 +23,44 @@ |
||
23 | 23 | class RouteMatchSpecificationFactory extends FactoryWithDependencyResolver |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * RouteMatchSpecificationFactory constructor |
|
28 | - * |
|
29 | - * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
30 | - * @param LoaderInterface $loader |
|
31 | - */ |
|
32 | - public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
33 | - { |
|
34 | - parent::__construct($dependency_resolver, $loader); |
|
35 | - } |
|
26 | + /** |
|
27 | + * RouteMatchSpecificationFactory constructor |
|
28 | + * |
|
29 | + * @param RouteMatchSpecificationDependencyResolver $dependency_resolver |
|
30 | + * @param LoaderInterface $loader |
|
31 | + */ |
|
32 | + public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader) |
|
33 | + { |
|
34 | + parent::__construct($dependency_resolver, $loader); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @param $fqcn |
|
40 | - * @return RouteMatchSpecification |
|
41 | - * @since 4.9.71.p |
|
42 | - */ |
|
43 | - public function createNewRouteMatchSpecification($fqcn) |
|
44 | - { |
|
45 | - $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
46 | - return $this->loader()->getShared($fqcn); |
|
47 | - } |
|
38 | + /** |
|
39 | + * @param $fqcn |
|
40 | + * @return RouteMatchSpecification |
|
41 | + * @since 4.9.71.p |
|
42 | + */ |
|
43 | + public function createNewRouteMatchSpecification($fqcn) |
|
44 | + { |
|
45 | + $this->dependencyResolver()->resolveDependenciesForClass($fqcn); |
|
46 | + return $this->loader()->getShared($fqcn); |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $fqcn |
|
52 | - * @return RouteMatchSpecification |
|
53 | - * @throws InvalidArgumentException |
|
54 | - * @throws InvalidDataTypeException |
|
55 | - * @throws InvalidInterfaceException |
|
56 | - * @since 4.9.71.p |
|
57 | - */ |
|
58 | - public static function create($fqcn) |
|
59 | - { |
|
60 | - /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
61 | - $specification_factory = LoaderFactory::getLoader()->getShared( |
|
62 | - 'EventEspresso\core\services\routes\RouteMatchSpecificationFactory' |
|
63 | - ); |
|
64 | - return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
65 | - } |
|
50 | + /** |
|
51 | + * @param $fqcn |
|
52 | + * @return RouteMatchSpecification |
|
53 | + * @throws InvalidArgumentException |
|
54 | + * @throws InvalidDataTypeException |
|
55 | + * @throws InvalidInterfaceException |
|
56 | + * @since 4.9.71.p |
|
57 | + */ |
|
58 | + public static function create($fqcn) |
|
59 | + { |
|
60 | + /** @var RouteMatchSpecificationFactory $specification_factory */ |
|
61 | + $specification_factory = LoaderFactory::getLoader()->getShared( |
|
62 | + 'EventEspresso\core\services\routes\RouteMatchSpecificationFactory' |
|
63 | + ); |
|
64 | + return $specification_factory->createNewRouteMatchSpecification($fqcn); |
|
65 | + } |
|
66 | 66 | } |
@@ -20,83 +20,83 @@ |
||
20 | 20 | class RouteHandler |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var LoaderInterface $loader |
|
25 | - */ |
|
26 | - private $loader; |
|
23 | + /** |
|
24 | + * @var LoaderInterface $loader |
|
25 | + */ |
|
26 | + private $loader; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var RouteCollection $routes |
|
30 | - */ |
|
31 | - private $routes; |
|
28 | + /** |
|
29 | + * @var RouteCollection $routes |
|
30 | + */ |
|
31 | + private $routes; |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * AdminRouter constructor. |
|
36 | - * |
|
37 | - * @param LoaderInterface $loader |
|
38 | - * @param RouteCollection $routes |
|
39 | - */ |
|
40 | - public function __construct( |
|
41 | - LoaderInterface $loader, |
|
42 | - RouteCollection $routes |
|
43 | - ) { |
|
44 | - $this->loader = $loader; |
|
45 | - $this->routes = $routes; |
|
46 | - } |
|
34 | + /** |
|
35 | + * AdminRouter constructor. |
|
36 | + * |
|
37 | + * @param LoaderInterface $loader |
|
38 | + * @param RouteCollection $routes |
|
39 | + */ |
|
40 | + public function __construct( |
|
41 | + LoaderInterface $loader, |
|
42 | + RouteCollection $routes |
|
43 | + ) { |
|
44 | + $this->loader = $loader; |
|
45 | + $this->routes = $routes; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * @param string $fqcn Fully Qualified Class Name for Route |
|
51 | - * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
52 | - * @throws Exception |
|
53 | - * @since $VID:$ |
|
54 | - */ |
|
55 | - public function addRoute($fqcn, $handle = true) |
|
56 | - { |
|
57 | - try { |
|
58 | - $route = $this->loader->getShared($fqcn); |
|
59 | - if (! $route instanceof RouteInterface) { |
|
60 | - throw new InvalidClassException( |
|
61 | - sprintf( |
|
62 | - esc_html__( |
|
63 | - 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
64 | - 'eventespresso' |
|
65 | - ), |
|
66 | - $fqcn |
|
67 | - ) |
|
68 | - ); |
|
69 | - } |
|
70 | - $this->routes->add($route); |
|
71 | - if ($handle) { |
|
72 | - $route->handleRequest(); |
|
73 | - } |
|
74 | - } catch (Exception $exception) { |
|
75 | - new ExceptionStackTraceDisplay($exception); |
|
76 | - } |
|
77 | - } |
|
49 | + /** |
|
50 | + * @param string $fqcn Fully Qualified Class Name for Route |
|
51 | + * @param bool $handle if true [default] will immediately call RouteInterface::handleRequest() |
|
52 | + * @throws Exception |
|
53 | + * @since $VID:$ |
|
54 | + */ |
|
55 | + public function addRoute($fqcn, $handle = true) |
|
56 | + { |
|
57 | + try { |
|
58 | + $route = $this->loader->getShared($fqcn); |
|
59 | + if (! $route instanceof RouteInterface) { |
|
60 | + throw new InvalidClassException( |
|
61 | + sprintf( |
|
62 | + esc_html__( |
|
63 | + 'The supplied FQCN (%1$s) must be an instance of RouteInterface.', |
|
64 | + 'eventespresso' |
|
65 | + ), |
|
66 | + $fqcn |
|
67 | + ) |
|
68 | + ); |
|
69 | + } |
|
70 | + $this->routes->add($route); |
|
71 | + if ($handle) { |
|
72 | + $route->handleRequest(); |
|
73 | + } |
|
74 | + } catch (Exception $exception) { |
|
75 | + new ExceptionStackTraceDisplay($exception); |
|
76 | + } |
|
77 | + } |
|
78 | 78 | |
79 | 79 | |
80 | - /** |
|
81 | - * finds and returns all Routes that have yet to be handled |
|
82 | - * |
|
83 | - * @return RouteInterface[] |
|
84 | - */ |
|
85 | - public function getRoutesForCurrentRequest() |
|
86 | - { |
|
87 | - return $this->routes->getRoutesForCurrentRequest(); |
|
88 | - } |
|
80 | + /** |
|
81 | + * finds and returns all Routes that have yet to be handled |
|
82 | + * |
|
83 | + * @return RouteInterface[] |
|
84 | + */ |
|
85 | + public function getRoutesForCurrentRequest() |
|
86 | + { |
|
87 | + return $this->routes->getRoutesForCurrentRequest(); |
|
88 | + } |
|
89 | 89 | |
90 | 90 | |
91 | - /** |
|
92 | - * calls RouteInterface::handleRequest() on all Routes that |
|
93 | - * - match current request |
|
94 | - * - have yet to be handled |
|
95 | - * |
|
96 | - * @return void |
|
97 | - */ |
|
98 | - public function handleRoutesForCurrentRequest() |
|
99 | - { |
|
100 | - $this->routes->handleRoutesForCurrentRequest(); |
|
101 | - } |
|
91 | + /** |
|
92 | + * calls RouteInterface::handleRequest() on all Routes that |
|
93 | + * - match current request |
|
94 | + * - have yet to be handled |
|
95 | + * |
|
96 | + * @return void |
|
97 | + */ |
|
98 | + public function handleRoutesForCurrentRequest() |
|
99 | + { |
|
100 | + $this->routes->handleRoutesForCurrentRequest(); |
|
101 | + } |
|
102 | 102 | } |
@@ -56,7 +56,7 @@ |
||
56 | 56 | { |
57 | 57 | try { |
58 | 58 | $route = $this->loader->getShared($fqcn); |
59 | - if (! $route instanceof RouteInterface) { |
|
59 | + if ( ! $route instanceof RouteInterface) { |
|
60 | 60 | throw new InvalidClassException( |
61 | 61 | sprintf( |
62 | 62 | esc_html__( |
@@ -16,36 +16,36 @@ |
||
16 | 16 | class RouteMatchSpecificationCollection extends Collection |
17 | 17 | { |
18 | 18 | |
19 | - const COLLECTION_NAME = 'route_match_specifications'; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * RouteMatchSpecificationCollection constructor |
|
24 | - * |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - public function __construct() |
|
28 | - { |
|
29 | - parent::__construct( |
|
30 | - 'EventEspresso\core\domain\entities\routes\specifications\RouteMatchSpecificationInterface', |
|
31 | - RouteMatchSpecificationCollection::COLLECTION_NAME |
|
32 | - ); |
|
33 | - } |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * getIdentifier |
|
38 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
39 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
40 | - * |
|
41 | - * @param $object |
|
42 | - * @param mixed $identifier |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function getIdentifier($object, $identifier = null) |
|
46 | - { |
|
47 | - return ! empty($identifier) |
|
48 | - ? $identifier |
|
49 | - : get_class($object); |
|
50 | - } |
|
19 | + const COLLECTION_NAME = 'route_match_specifications'; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * RouteMatchSpecificationCollection constructor |
|
24 | + * |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + public function __construct() |
|
28 | + { |
|
29 | + parent::__construct( |
|
30 | + 'EventEspresso\core\domain\entities\routes\specifications\RouteMatchSpecificationInterface', |
|
31 | + RouteMatchSpecificationCollection::COLLECTION_NAME |
|
32 | + ); |
|
33 | + } |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * getIdentifier |
|
38 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
39 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
40 | + * |
|
41 | + * @param $object |
|
42 | + * @param mixed $identifier |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function getIdentifier($object, $identifier = null) |
|
46 | + { |
|
47 | + return ! empty($identifier) |
|
48 | + ? $identifier |
|
49 | + : get_class($object); |
|
50 | + } |
|
51 | 51 | } |