@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | { |
37 | 37 | if (isset($input_settings['value_field_name'])) { |
38 | 38 | $this->valueFieldName = $input_settings['value_field_name']; |
39 | - if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
39 | + if ( ! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
40 | 40 | throw new InvalidArgumentException( |
41 | 41 | sprintf( |
42 | 42 | esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this |
54 | 54 | ); |
55 | 55 | $input_settings['html_class'] = isset($input_settings['html_class']) |
56 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
56 | + ? $input_settings['html_class'].' ee-state-select-js' |
|
57 | 57 | : 'ee-state-select-js'; |
58 | 58 | parent::__construct($state_options, $input_settings); |
59 | 59 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function get_state_answer_options($state_options = null) |
84 | 84 | { |
85 | 85 | // if passed something that is NOT an array |
86 | - if (! is_array($state_options) || empty($state_options)) { |
|
86 | + if ( ! is_array($state_options) || empty($state_options)) { |
|
87 | 87 | // get possibly cached list of states |
88 | 88 | $states = EEM_State::instance()->get_all_active_states(); |
89 | 89 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | $states = $state_options; |
92 | 92 | $state_options = array(); |
93 | 93 | } |
94 | - if (! empty($states)) { |
|
94 | + if ( ! empty($states)) { |
|
95 | 95 | // set the default |
96 | 96 | $state_options[''][''] = ''; |
97 | 97 | foreach ($states as $state) { |
98 | 98 | if ($state instanceof EE_State) { |
99 | - $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
99 | + $state_options[$state->country()->name()][$state->get($this->valueFieldName())] = $state->name(); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -12,94 +12,94 @@ |
||
12 | 12 | */ |
13 | 13 | class EE_State_Select_Input extends EE_Select_Input |
14 | 14 | { |
15 | - /** |
|
16 | - * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
17 | - */ |
|
18 | - protected $valueFieldName; |
|
15 | + /** |
|
16 | + * @var string the name of the EE_State field to use for option values in the HTML form input. |
|
17 | + */ |
|
18 | + protected $valueFieldName; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
22 | - * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
23 | - * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
24 | - * and $input_settings['value_field_name'] will again be used. * |
|
25 | - * @param array $input_settings same as parent, but also { |
|
26 | - * @type string $value_field_name the name of the field to use |
|
27 | - * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
28 | - * } |
|
29 | - * @throws EE_Error |
|
30 | - * @throws InvalidArgumentException |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - * @throws InvalidInterfaceException |
|
33 | - * @throws ReflectionException |
|
34 | - */ |
|
35 | - public function __construct($state_options, $input_settings = array()) |
|
36 | - { |
|
37 | - if (isset($input_settings['value_field_name'])) { |
|
38 | - $this->valueFieldName = $input_settings['value_field_name']; |
|
39 | - if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
40 | - throw new InvalidArgumentException( |
|
41 | - sprintf( |
|
42 | - esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
43 | - $this->valueFieldName() |
|
44 | - ) |
|
45 | - ); |
|
46 | - } |
|
47 | - } else { |
|
48 | - $this->valueFieldName = 'STA_ID'; |
|
49 | - } |
|
50 | - $state_options = apply_filters( |
|
51 | - 'FHEE__EE_State_Select_Input____construct__state_options', |
|
52 | - $this->get_state_answer_options($state_options), |
|
53 | - $this |
|
54 | - ); |
|
55 | - $input_settings['html_class'] = isset($input_settings['html_class']) |
|
56 | - ? $input_settings['html_class'] . ' ee-state-select-js' |
|
57 | - : 'ee-state-select-js'; |
|
58 | - parent::__construct($state_options, $input_settings); |
|
59 | - } |
|
20 | + /** |
|
21 | + * @param EE_State[]|array|null $state_options. If a flat array of string is provided, |
|
22 | + * $input_settings['value_field_name'] is ignored. If an array of states is passed, that field will be used for |
|
23 | + * the keys (which will become the option values). If null or empty is passed, all active states will be used, |
|
24 | + * and $input_settings['value_field_name'] will again be used. * |
|
25 | + * @param array $input_settings same as parent, but also { |
|
26 | + * @type string $value_field_name the name of the field to use |
|
27 | + * for the HTML option values, ie, `STA_ID`, `STA_abbrev`, or `STA_name`. |
|
28 | + * } |
|
29 | + * @throws EE_Error |
|
30 | + * @throws InvalidArgumentException |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + * @throws InvalidInterfaceException |
|
33 | + * @throws ReflectionException |
|
34 | + */ |
|
35 | + public function __construct($state_options, $input_settings = array()) |
|
36 | + { |
|
37 | + if (isset($input_settings['value_field_name'])) { |
|
38 | + $this->valueFieldName = $input_settings['value_field_name']; |
|
39 | + if (! EEM_State::instance()->has_field((string) $this->valueFieldName())) { |
|
40 | + throw new InvalidArgumentException( |
|
41 | + sprintf( |
|
42 | + esc_html__('An invalid state field "%1$s" was specified for the state input\'s option values.', 'event_espresso'), |
|
43 | + $this->valueFieldName() |
|
44 | + ) |
|
45 | + ); |
|
46 | + } |
|
47 | + } else { |
|
48 | + $this->valueFieldName = 'STA_ID'; |
|
49 | + } |
|
50 | + $state_options = apply_filters( |
|
51 | + 'FHEE__EE_State_Select_Input____construct__state_options', |
|
52 | + $this->get_state_answer_options($state_options), |
|
53 | + $this |
|
54 | + ); |
|
55 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
56 | + ? $input_settings['html_class'] . ' ee-state-select-js' |
|
57 | + : 'ee-state-select-js'; |
|
58 | + parent::__construct($state_options, $input_settings); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Returns the name of the state field used for the HTML option values. |
|
63 | - * @since 4.10.0.p |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public function valueFieldName() |
|
67 | - { |
|
68 | - return $this->valueFieldName; |
|
69 | - } |
|
61 | + /** |
|
62 | + * Returns the name of the state field used for the HTML option values. |
|
63 | + * @since 4.10.0.p |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public function valueFieldName() |
|
67 | + { |
|
68 | + return $this->valueFieldName; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * get_state_answer_options |
|
74 | - * |
|
75 | - * @param array $state_options |
|
76 | - * @return array |
|
77 | - * @throws EE_Error |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws ReflectionException |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws InvalidInterfaceException |
|
82 | - */ |
|
83 | - public function get_state_answer_options($state_options = null) |
|
84 | - { |
|
85 | - // if passed something that is NOT an array |
|
86 | - if (! is_array($state_options) || empty($state_options)) { |
|
87 | - // get possibly cached list of states |
|
88 | - $states = EEM_State::instance()->get_all_active_states(); |
|
89 | - } |
|
90 | - if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
91 | - $states = $state_options; |
|
92 | - $state_options = array(); |
|
93 | - } |
|
94 | - if (! empty($states)) { |
|
95 | - // set the default |
|
96 | - $state_options[''][''] = ''; |
|
97 | - foreach ($states as $state) { |
|
98 | - if ($state instanceof EE_State) { |
|
99 | - $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
103 | - return $state_options ?? []; |
|
104 | - } |
|
72 | + /** |
|
73 | + * get_state_answer_options |
|
74 | + * |
|
75 | + * @param array $state_options |
|
76 | + * @return array |
|
77 | + * @throws EE_Error |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws ReflectionException |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws InvalidInterfaceException |
|
82 | + */ |
|
83 | + public function get_state_answer_options($state_options = null) |
|
84 | + { |
|
85 | + // if passed something that is NOT an array |
|
86 | + if (! is_array($state_options) || empty($state_options)) { |
|
87 | + // get possibly cached list of states |
|
88 | + $states = EEM_State::instance()->get_all_active_states(); |
|
89 | + } |
|
90 | + if (is_array($state_options) && reset($state_options) instanceof EE_State) { |
|
91 | + $states = $state_options; |
|
92 | + $state_options = array(); |
|
93 | + } |
|
94 | + if (! empty($states)) { |
|
95 | + // set the default |
|
96 | + $state_options[''][''] = ''; |
|
97 | + foreach ($states as $state) { |
|
98 | + if ($state instanceof EE_State) { |
|
99 | + $state_options[ $state->country()->name() ][ $state->get($this->valueFieldName()) ] = $state->name(); |
|
100 | + } |
|
101 | + } |
|
102 | + } |
|
103 | + return $state_options ?? []; |
|
104 | + } |
|
105 | 105 | } |
@@ -23,15 +23,15 @@ |
||
23 | 23 | public function __construct() |
24 | 24 | { |
25 | 25 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
26 | - if (! defined('REG_PG_SLUG')) { |
|
26 | + if ( ! defined('REG_PG_SLUG')) { |
|
27 | 27 | define('REG_PG_SLUG', 'espresso_registrations'); |
28 | 28 | define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG))); |
29 | - define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/'); |
|
30 | - define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG)); |
|
31 | - define('REG_ASSETS_PATH', REG_ADMIN . 'assets/'); |
|
32 | - define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/'); |
|
33 | - define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/'); |
|
34 | - define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/'); |
|
29 | + define('REG_ADMIN', EE_ADMIN_PAGES.'registrations/'); |
|
30 | + define('REG_ADMIN_URL', admin_url('admin.php?page='.REG_PG_SLUG)); |
|
31 | + define('REG_ASSETS_PATH', REG_ADMIN.'assets/'); |
|
32 | + define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL.'registrations/assets/'); |
|
33 | + define('REG_TEMPLATE_PATH', REG_ADMIN.'templates/'); |
|
34 | + define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL.'registrations/templates/'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | parent::__construct(); |
@@ -11,48 +11,48 @@ |
||
11 | 11 | */ |
12 | 12 | class Registrations_Admin_Page_Init extends EE_Admin_Page_CPT_Init |
13 | 13 | { |
14 | - /** |
|
15 | - * constructor |
|
16 | - * |
|
17 | - * @Constructor |
|
18 | - * @access public |
|
19 | - * @return void |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
24 | - if (! defined('REG_PG_SLUG')) { |
|
25 | - define('REG_PG_SLUG', 'espresso_registrations'); |
|
26 | - define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG))); |
|
27 | - define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/'); |
|
28 | - define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG)); |
|
29 | - define('REG_ASSETS_PATH', REG_ADMIN . 'assets/'); |
|
30 | - define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/'); |
|
31 | - define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/'); |
|
32 | - define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/'); |
|
33 | - } |
|
14 | + /** |
|
15 | + * constructor |
|
16 | + * |
|
17 | + * @Constructor |
|
18 | + * @access public |
|
19 | + * @return void |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
24 | + if (! defined('REG_PG_SLUG')) { |
|
25 | + define('REG_PG_SLUG', 'espresso_registrations'); |
|
26 | + define('REG_PG_NAME', ucwords(str_replace('_', '', REG_PG_SLUG))); |
|
27 | + define('REG_ADMIN', EE_ADMIN_PAGES . 'registrations/'); |
|
28 | + define('REG_ADMIN_URL', admin_url('admin.php?page=' . REG_PG_SLUG)); |
|
29 | + define('REG_ASSETS_PATH', REG_ADMIN . 'assets/'); |
|
30 | + define('REG_ASSETS_URL', EE_ADMIN_PAGES_URL . 'registrations/assets/'); |
|
31 | + define('REG_TEMPLATE_PATH', REG_ADMIN . 'templates/'); |
|
32 | + define('REG_TEMPLATE_URL', EE_ADMIN_PAGES_URL . 'registrations/templates/'); |
|
33 | + } |
|
34 | 34 | |
35 | - parent::__construct(); |
|
36 | - } |
|
35 | + parent::__construct(); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - protected function _set_init_properties() |
|
40 | - { |
|
41 | - $this->label = esc_html__('Registrations Overview', 'event_espresso'); |
|
42 | - } |
|
39 | + protected function _set_init_properties() |
|
40 | + { |
|
41 | + $this->label = esc_html__('Registrations Overview', 'event_espresso'); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - public function getMenuProperties(): array |
|
46 | - { |
|
47 | - return [ |
|
48 | - 'menu_type' => AdminMenuItem::TYPE_MENU_SUB_ITEM, |
|
49 | - 'menu_group' => 'main', |
|
50 | - 'menu_order' => 40, |
|
51 | - 'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY, |
|
52 | - 'parent_slug' => 'espresso_events', |
|
53 | - 'menu_slug' => REG_PG_SLUG, |
|
54 | - 'menu_label' => esc_html__('Registrations', 'event_espresso'), |
|
55 | - 'capability' => 'ee_read_registrations', |
|
56 | - ]; |
|
57 | - } |
|
45 | + public function getMenuProperties(): array |
|
46 | + { |
|
47 | + return [ |
|
48 | + 'menu_type' => AdminMenuItem::TYPE_MENU_SUB_ITEM, |
|
49 | + 'menu_group' => 'main', |
|
50 | + 'menu_order' => 40, |
|
51 | + 'show_on_menu' => AdminMenuItem::DISPLAY_BLOG_ONLY, |
|
52 | + 'parent_slug' => 'espresso_events', |
|
53 | + 'menu_slug' => REG_PG_SLUG, |
|
54 | + 'menu_label' => esc_html__('Registrations', 'event_espresso'), |
|
55 | + 'capability' => 'ee_read_registrations', |
|
56 | + ]; |
|
57 | + } |
|
58 | 58 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | // load interfaces |
200 | 200 | espresso_load_required( |
201 | 201 | 'EEH_Autoloader', |
202 | - EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
202 | + EE_CORE.'helpers/EEH_Autoloader.helper.php' |
|
203 | 203 | ); |
204 | 204 | EEH_Autoloader::instance(); |
205 | 205 | } |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | protected function setAutoloadersForRequiredFiles() |
214 | 214 | { |
215 | 215 | // load interfaces |
216 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
216 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces', true); |
|
217 | 217 | // load helpers |
218 | 218 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
219 | 219 | // register legacy request stack classes just in case |
220 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
220 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'request_stack/'); |
|
221 | 221 | // register legacy middleware classes just in case |
222 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
222 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'middleware/'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 |
@@ -53,212 +53,212 @@ |
||
53 | 53 | */ |
54 | 54 | class BootstrapCore |
55 | 55 | { |
56 | - private LoaderInterface $loader; |
|
56 | + private LoaderInterface $loader; |
|
57 | 57 | |
58 | - protected RequestInterface $request; |
|
58 | + protected RequestInterface $request; |
|
59 | 59 | |
60 | - protected ResponseInterface $response; |
|
60 | + protected ResponseInterface $response; |
|
61 | 61 | |
62 | - protected RequestStackBuilder $request_stack_builder; |
|
62 | + protected RequestStackBuilder $request_stack_builder; |
|
63 | 63 | |
64 | - protected RequestStack $request_stack; |
|
64 | + protected RequestStack $request_stack; |
|
65 | 65 | |
66 | 66 | |
67 | - /** |
|
68 | - * BootstrapCore constructor. |
|
69 | - */ |
|
70 | - public function __construct() |
|
71 | - { |
|
72 | - do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct'); |
|
73 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
74 | - add_action('plugins_loaded', [$this, 'initialize'], 0); |
|
75 | - } |
|
67 | + /** |
|
68 | + * BootstrapCore constructor. |
|
69 | + */ |
|
70 | + public function __construct() |
|
71 | + { |
|
72 | + do_action('AHEE__EventEspresso_core_services_bootstrap_BootstrapCore___construct'); |
|
73 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
74 | + add_action('plugins_loaded', [$this, 'initialize'], 0); |
|
75 | + } |
|
76 | 76 | |
77 | 77 | |
78 | - /** |
|
79 | - * @throws DomainException |
|
80 | - * @throws EE_Error |
|
81 | - * @throws Exception |
|
82 | - * @throws InvalidArgumentException |
|
83 | - * @throws InvalidClassException |
|
84 | - * @throws InvalidDataTypeException |
|
85 | - * @throws InvalidFilePathException |
|
86 | - * @throws InvalidInterfaceException |
|
87 | - * @throws InvalidRequestStackMiddlewareException |
|
88 | - * @throws OutOfBoundsException |
|
89 | - * @throws ReflectionException |
|
90 | - * @throws Throwable |
|
91 | - */ |
|
92 | - public function initialize() |
|
93 | - { |
|
94 | - $this->bootstrapDependencyInjectionContainer(); |
|
95 | - $this->bootstrapDomain(); |
|
96 | - $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
97 | - add_action( |
|
98 | - 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
99 | - [$bootstrap_request, 'setupLegacyRequest'] |
|
100 | - ); |
|
101 | - $this->runRequestStack(); |
|
102 | - } |
|
78 | + /** |
|
79 | + * @throws DomainException |
|
80 | + * @throws EE_Error |
|
81 | + * @throws Exception |
|
82 | + * @throws InvalidArgumentException |
|
83 | + * @throws InvalidClassException |
|
84 | + * @throws InvalidDataTypeException |
|
85 | + * @throws InvalidFilePathException |
|
86 | + * @throws InvalidInterfaceException |
|
87 | + * @throws InvalidRequestStackMiddlewareException |
|
88 | + * @throws OutOfBoundsException |
|
89 | + * @throws ReflectionException |
|
90 | + * @throws Throwable |
|
91 | + */ |
|
92 | + public function initialize() |
|
93 | + { |
|
94 | + $this->bootstrapDependencyInjectionContainer(); |
|
95 | + $this->bootstrapDomain(); |
|
96 | + $bootstrap_request = $this->bootstrapRequestResponseObjects(); |
|
97 | + add_action( |
|
98 | + 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', |
|
99 | + [$bootstrap_request, 'setupLegacyRequest'] |
|
100 | + ); |
|
101 | + $this->runRequestStack(); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * @throws ReflectionException |
|
107 | - * @throws EE_Error |
|
108 | - * @throws InvalidArgumentException |
|
109 | - * @throws InvalidDataTypeException |
|
110 | - * @throws InvalidInterfaceException |
|
111 | - * @throws OutOfBoundsException |
|
112 | - */ |
|
113 | - private function bootstrapDependencyInjectionContainer() |
|
114 | - { |
|
115 | - $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
116 | - $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
117 | - $bootstrap_di->buildLoader(); |
|
118 | - $registry = $bootstrap_di->getRegistry(); |
|
119 | - $dependency_map = $bootstrap_di->getDependencyMap(); |
|
120 | - $dependency_map->initialize(); |
|
121 | - $registry->initialize(); |
|
122 | - $this->loader = $bootstrap_di->getLoader(); |
|
123 | - } |
|
105 | + /** |
|
106 | + * @throws ReflectionException |
|
107 | + * @throws EE_Error |
|
108 | + * @throws InvalidArgumentException |
|
109 | + * @throws InvalidDataTypeException |
|
110 | + * @throws InvalidInterfaceException |
|
111 | + * @throws OutOfBoundsException |
|
112 | + */ |
|
113 | + private function bootstrapDependencyInjectionContainer() |
|
114 | + { |
|
115 | + $bootstrap_di = new BootstrapDependencyInjectionContainer(); |
|
116 | + $bootstrap_di->buildLegacyDependencyInjectionContainer(); |
|
117 | + $bootstrap_di->buildLoader(); |
|
118 | + $registry = $bootstrap_di->getRegistry(); |
|
119 | + $dependency_map = $bootstrap_di->getDependencyMap(); |
|
120 | + $dependency_map->initialize(); |
|
121 | + $registry->initialize(); |
|
122 | + $this->loader = $bootstrap_di->getLoader(); |
|
123 | + } |
|
124 | 124 | |
125 | 125 | |
126 | - /** |
|
127 | - * configures the Domain object for core |
|
128 | - * |
|
129 | - * @return void |
|
130 | - * @throws DomainException |
|
131 | - * @throws InvalidArgumentException |
|
132 | - * @throws InvalidDataTypeException |
|
133 | - * @throws InvalidClassException |
|
134 | - * @throws InvalidFilePathException |
|
135 | - * @throws InvalidInterfaceException |
|
136 | - */ |
|
137 | - private function bootstrapDomain() |
|
138 | - { |
|
139 | - DomainFactory::getEventEspressoCoreDomain(); |
|
140 | - } |
|
126 | + /** |
|
127 | + * configures the Domain object for core |
|
128 | + * |
|
129 | + * @return void |
|
130 | + * @throws DomainException |
|
131 | + * @throws InvalidArgumentException |
|
132 | + * @throws InvalidDataTypeException |
|
133 | + * @throws InvalidClassException |
|
134 | + * @throws InvalidFilePathException |
|
135 | + * @throws InvalidInterfaceException |
|
136 | + */ |
|
137 | + private function bootstrapDomain() |
|
138 | + { |
|
139 | + DomainFactory::getEventEspressoCoreDomain(); |
|
140 | + } |
|
141 | 141 | |
142 | 142 | |
143 | - /** |
|
144 | - * sets up the request and response objects |
|
145 | - * |
|
146 | - * @return BootstrapRequestResponseObjects |
|
147 | - * @throws InvalidArgumentException |
|
148 | - */ |
|
149 | - private function bootstrapRequestResponseObjects(): BootstrapRequestResponseObjects |
|
150 | - { |
|
151 | - /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
152 | - $bootstrap_request = $this->loader->getShared( |
|
153 | - 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
154 | - [$this->loader] |
|
155 | - ); |
|
156 | - $bootstrap_request->buildRequestResponse(); |
|
157 | - $bootstrap_request->shareRequestResponse(); |
|
158 | - $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
159 | - $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
160 | - return $bootstrap_request; |
|
161 | - } |
|
143 | + /** |
|
144 | + * sets up the request and response objects |
|
145 | + * |
|
146 | + * @return BootstrapRequestResponseObjects |
|
147 | + * @throws InvalidArgumentException |
|
148 | + */ |
|
149 | + private function bootstrapRequestResponseObjects(): BootstrapRequestResponseObjects |
|
150 | + { |
|
151 | + /** @var BootstrapRequestResponseObjects $bootstrap_request */ |
|
152 | + $bootstrap_request = $this->loader->getShared( |
|
153 | + 'EventEspresso\core\services\bootstrap\BootstrapRequestResponseObjects', |
|
154 | + [$this->loader] |
|
155 | + ); |
|
156 | + $bootstrap_request->buildRequestResponse(); |
|
157 | + $bootstrap_request->shareRequestResponse(); |
|
158 | + $this->request = $this->loader->getShared('EventEspresso\core\services\request\Request'); |
|
159 | + $this->response = $this->loader->getShared('EventEspresso\core\services\request\Response'); |
|
160 | + return $bootstrap_request; |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | - /** |
|
165 | - * run_request_stack |
|
166 | - * construct request stack and run middleware apps |
|
167 | - * |
|
168 | - * @throws EE_Error |
|
169 | - * @throws Exception |
|
170 | - * @throws Throwable |
|
171 | - */ |
|
172 | - public function runRequestStack() |
|
173 | - { |
|
174 | - $this->loadAutoloader(); |
|
175 | - $this->setAutoloadersForRequiredFiles(); |
|
176 | - $this->request_stack_builder = $this->buildRequestStack(); |
|
177 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
178 | - new RequestStackCoreApp() |
|
179 | - ); |
|
180 | - $this->request_stack->handleRequest($this->request, $this->response); |
|
181 | - $this->request_stack->handleResponse(); |
|
182 | - } |
|
164 | + /** |
|
165 | + * run_request_stack |
|
166 | + * construct request stack and run middleware apps |
|
167 | + * |
|
168 | + * @throws EE_Error |
|
169 | + * @throws Exception |
|
170 | + * @throws Throwable |
|
171 | + */ |
|
172 | + public function runRequestStack() |
|
173 | + { |
|
174 | + $this->loadAutoloader(); |
|
175 | + $this->setAutoloadersForRequiredFiles(); |
|
176 | + $this->request_stack_builder = $this->buildRequestStack(); |
|
177 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
178 | + new RequestStackCoreApp() |
|
179 | + ); |
|
180 | + $this->request_stack->handleRequest($this->request, $this->response); |
|
181 | + $this->request_stack->handleResponse(); |
|
182 | + } |
|
183 | 183 | |
184 | 184 | |
185 | - /** |
|
186 | - * load_autoloader |
|
187 | - * |
|
188 | - * @throws EE_Error |
|
189 | - */ |
|
190 | - protected function loadAutoloader() |
|
191 | - { |
|
192 | - // load interfaces |
|
193 | - espresso_load_required( |
|
194 | - 'EEH_Autoloader', |
|
195 | - EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
196 | - ); |
|
197 | - EEH_Autoloader::instance(); |
|
198 | - } |
|
185 | + /** |
|
186 | + * load_autoloader |
|
187 | + * |
|
188 | + * @throws EE_Error |
|
189 | + */ |
|
190 | + protected function loadAutoloader() |
|
191 | + { |
|
192 | + // load interfaces |
|
193 | + espresso_load_required( |
|
194 | + 'EEH_Autoloader', |
|
195 | + EE_CORE . 'helpers/EEH_Autoloader.helper.php' |
|
196 | + ); |
|
197 | + EEH_Autoloader::instance(); |
|
198 | + } |
|
199 | 199 | |
200 | 200 | |
201 | - /** |
|
202 | - * load_required_files |
|
203 | - * |
|
204 | - * @throws EE_Error |
|
205 | - */ |
|
206 | - protected function setAutoloadersForRequiredFiles() |
|
207 | - { |
|
208 | - // load interfaces |
|
209 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
210 | - // load helpers |
|
211 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
212 | - // register legacy request stack classes just in case |
|
213 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
214 | - // register legacy middleware classes just in case |
|
215 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
216 | - } |
|
201 | + /** |
|
202 | + * load_required_files |
|
203 | + * |
|
204 | + * @throws EE_Error |
|
205 | + */ |
|
206 | + protected function setAutoloadersForRequiredFiles() |
|
207 | + { |
|
208 | + // load interfaces |
|
209 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
210 | + // load helpers |
|
211 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
212 | + // register legacy request stack classes just in case |
|
213 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack/'); |
|
214 | + // register legacy middleware classes just in case |
|
215 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware/'); |
|
216 | + } |
|
217 | 217 | |
218 | 218 | |
219 | - /** |
|
220 | - * build_request_stack |
|
221 | - * |
|
222 | - * @return RequestStackBuilder |
|
223 | - */ |
|
224 | - public function buildRequestStack(): RequestStackBuilder |
|
225 | - { |
|
226 | - $request_stack_builder = new RequestStackBuilder($this->loader); |
|
227 | - /** |
|
228 | - * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
229 | - * so items at the beginning of the final middleware stack will run last. |
|
230 | - * First parameter is the middleware classname, second is an array of arguments |
|
231 | - */ |
|
232 | - $stack_apps = apply_filters( |
|
233 | - 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
234 | - [ |
|
235 | - // first in last out |
|
236 | - BotDetector::class => [], |
|
237 | - DetectFileEditorRequest::class => [], |
|
238 | - PreProductionVersionWarning::class => [], |
|
239 | - RecommendedVersions::class => [], |
|
240 | - // last in first out |
|
241 | - DetectLogin::class => [], |
|
242 | - ] |
|
243 | - ); |
|
244 | - // legacy filter for backwards compatibility |
|
245 | - $stack_apps = apply_filters( |
|
246 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
247 | - $stack_apps |
|
248 | - ); |
|
249 | - // load middleware onto stack : FILO (First In Last Out) |
|
250 | - // items at the beginning of the $stack_apps array will run last |
|
251 | - foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
252 | - $request_stack_builder->push([$stack_app, $stack_app_args]); |
|
253 | - } |
|
254 | - // finally, we'll add this on its own because we need it to always be part of the stack |
|
255 | - // and we also need it to always run first because the rest of the system relies on it |
|
256 | - $request_stack_builder->push( |
|
257 | - [SetRequestTypeContextChecker::class, []] |
|
258 | - ); |
|
259 | - return apply_filters( |
|
260 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
261 | - $request_stack_builder |
|
262 | - ); |
|
263 | - } |
|
219 | + /** |
|
220 | + * build_request_stack |
|
221 | + * |
|
222 | + * @return RequestStackBuilder |
|
223 | + */ |
|
224 | + public function buildRequestStack(): RequestStackBuilder |
|
225 | + { |
|
226 | + $request_stack_builder = new RequestStackBuilder($this->loader); |
|
227 | + /** |
|
228 | + * ! IMPORTANT ! The middleware stack operates FILO : FIRST IN LAST OUT |
|
229 | + * so items at the beginning of the final middleware stack will run last. |
|
230 | + * First parameter is the middleware classname, second is an array of arguments |
|
231 | + */ |
|
232 | + $stack_apps = apply_filters( |
|
233 | + 'FHEE__EventEspresso_core_services_bootstrap_BootstrapCore__buildRequestStack__stack_apps', |
|
234 | + [ |
|
235 | + // first in last out |
|
236 | + BotDetector::class => [], |
|
237 | + DetectFileEditorRequest::class => [], |
|
238 | + PreProductionVersionWarning::class => [], |
|
239 | + RecommendedVersions::class => [], |
|
240 | + // last in first out |
|
241 | + DetectLogin::class => [], |
|
242 | + ] |
|
243 | + ); |
|
244 | + // legacy filter for backwards compatibility |
|
245 | + $stack_apps = apply_filters( |
|
246 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
247 | + $stack_apps |
|
248 | + ); |
|
249 | + // load middleware onto stack : FILO (First In Last Out) |
|
250 | + // items at the beginning of the $stack_apps array will run last |
|
251 | + foreach ((array) $stack_apps as $stack_app => $stack_app_args) { |
|
252 | + $request_stack_builder->push([$stack_app, $stack_app_args]); |
|
253 | + } |
|
254 | + // finally, we'll add this on its own because we need it to always be part of the stack |
|
255 | + // and we also need it to always run first because the rest of the system relies on it |
|
256 | + $request_stack_builder->push( |
|
257 | + [SetRequestTypeContextChecker::class, []] |
|
258 | + ); |
|
259 | + return apply_filters( |
|
260 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
261 | + $request_stack_builder |
|
262 | + ); |
|
263 | + } |
|
264 | 264 | } |
@@ -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/*.core.php', |
|
157 | + EE_CORE.'*.core.php', |
|
158 | + EE_ADMIN.'*.core.php', |
|
159 | + EE_CPTS.'*.core.php', |
|
160 | + EE_CORE.'data_migration_scripts/*.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 |
@@ -19,192 +19,192 @@ |
||
19 | 19 | */ |
20 | 20 | class OpenCoffeeShop |
21 | 21 | { |
22 | - /** |
|
23 | - * @var CoffeeShop $CoffeeShop |
|
24 | - */ |
|
25 | - private $CoffeeShop; |
|
22 | + /** |
|
23 | + * @var CoffeeShop $CoffeeShop |
|
24 | + */ |
|
25 | + private $CoffeeShop; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * OpenCoffeeShop constructor |
|
30 | - * |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - */ |
|
33 | - public function __construct() |
|
34 | - { |
|
35 | - // instantiate the DI container |
|
36 | - $this->CoffeeShop = new CoffeeShop(); |
|
37 | - } |
|
28 | + /** |
|
29 | + * OpenCoffeeShop constructor |
|
30 | + * |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + */ |
|
33 | + public function __construct() |
|
34 | + { |
|
35 | + // instantiate the DI container |
|
36 | + $this->CoffeeShop = new CoffeeShop(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | - /** |
|
42 | - * @return CoffeeShop |
|
43 | - */ |
|
44 | - public function CoffeeShop() |
|
45 | - { |
|
46 | - return $this->CoffeeShop; |
|
47 | - } |
|
40 | + // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | + /** |
|
42 | + * @return CoffeeShop |
|
43 | + */ |
|
44 | + public function CoffeeShop() |
|
45 | + { |
|
46 | + return $this->CoffeeShop; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * configure coffee makers which control the different kinds of brews |
|
52 | - * ( shared services, new factory objects, etc ) |
|
53 | - * |
|
54 | - * @throws InvalidEntityException |
|
55 | - */ |
|
56 | - public function setupCoffeeMakers() |
|
57 | - { |
|
58 | - // create a dependency injector class for resolving class constructor arguments |
|
59 | - $DependencyInjector = new DependencyInjector( |
|
60 | - $this->CoffeeShop, |
|
61 | - new \EEH_Array() |
|
62 | - ); |
|
63 | - // and some coffeemakers, one for creating new instances |
|
64 | - $this->CoffeeShop->addCoffeeMaker( |
|
65 | - new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
66 | - CoffeeMaker::BREW_NEW |
|
67 | - ); |
|
68 | - // one for shared services |
|
69 | - $this->CoffeeShop->addCoffeeMaker( |
|
70 | - new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
71 | - CoffeeMaker::BREW_SHARED |
|
72 | - ); |
|
73 | - // and one for classes that only get loaded |
|
74 | - $this->CoffeeShop->addCoffeeMaker( |
|
75 | - new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
76 | - CoffeeMaker::BREW_LOAD_ONLY |
|
77 | - ); |
|
78 | - } |
|
50 | + /** |
|
51 | + * configure coffee makers which control the different kinds of brews |
|
52 | + * ( shared services, new factory objects, etc ) |
|
53 | + * |
|
54 | + * @throws InvalidEntityException |
|
55 | + */ |
|
56 | + public function setupCoffeeMakers() |
|
57 | + { |
|
58 | + // create a dependency injector class for resolving class constructor arguments |
|
59 | + $DependencyInjector = new DependencyInjector( |
|
60 | + $this->CoffeeShop, |
|
61 | + new \EEH_Array() |
|
62 | + ); |
|
63 | + // and some coffeemakers, one for creating new instances |
|
64 | + $this->CoffeeShop->addCoffeeMaker( |
|
65 | + new NewCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
66 | + CoffeeMaker::BREW_NEW |
|
67 | + ); |
|
68 | + // one for shared services |
|
69 | + $this->CoffeeShop->addCoffeeMaker( |
|
70 | + new SharedCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
71 | + CoffeeMaker::BREW_SHARED |
|
72 | + ); |
|
73 | + // and one for classes that only get loaded |
|
74 | + $this->CoffeeShop->addCoffeeMaker( |
|
75 | + new LoadOnlyCoffeeMaker($this->CoffeeShop, $DependencyInjector), |
|
76 | + CoffeeMaker::BREW_LOAD_ONLY |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * Recipes define how to load legacy classes |
|
83 | - * |
|
84 | - * @throws InvalidIdentifierException |
|
85 | - */ |
|
86 | - public function addRecipes() |
|
87 | - { |
|
88 | - // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
89 | - // as long as they are not type hinting for interfaces |
|
90 | - $this->CoffeeShop->addRecipe( |
|
91 | - new Recipe( |
|
92 | - Recipe::DEFAULT_ID |
|
93 | - ) |
|
94 | - ); |
|
95 | - // PSR-4 compatible class with aliases |
|
96 | - $this->CoffeeShop->addRecipe( |
|
97 | - new Recipe( |
|
98 | - 'CommandHandlerManager', |
|
99 | - 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
100 | - array( |
|
101 | - 'CommandHandlerManagerInterface', |
|
102 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
103 | - ), |
|
104 | - array(), |
|
105 | - CoffeeMaker::BREW_SHARED |
|
106 | - ) |
|
107 | - ); |
|
108 | - // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
109 | - $this->CoffeeShop->addRecipe( |
|
110 | - new Recipe( |
|
111 | - 'CommandBus', |
|
112 | - 'EventEspresso\core\services\commands\CommandBus', |
|
113 | - array( |
|
114 | - 'CommandBusInterface', |
|
115 | - 'EventEspresso\core\services\commands\CommandBusInterface', |
|
116 | - ), |
|
117 | - array(), |
|
118 | - CoffeeMaker::BREW_SHARED |
|
119 | - ) |
|
120 | - ); |
|
121 | - // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
122 | - // add a wildcard recipe for loading legacy core interfaces |
|
123 | - $this->CoffeeShop->addRecipe( |
|
124 | - new Recipe( |
|
125 | - 'EEI_*', |
|
126 | - '', |
|
127 | - array(), |
|
128 | - array(), |
|
129 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
130 | - array( |
|
131 | - EE_INTERFACES . '*.php', |
|
132 | - EE_INTERFACES . '*.interfaces.php', |
|
133 | - ) |
|
134 | - ) |
|
135 | - ); |
|
136 | - // add a wildcard recipe for loading models |
|
137 | - $this->CoffeeShop->addRecipe( |
|
138 | - new Recipe( |
|
139 | - 'EEM_*', |
|
140 | - '', |
|
141 | - array(), |
|
142 | - array(), |
|
143 | - CoffeeMaker::BREW_SHARED, |
|
144 | - EE_MODELS . '*.model.php' |
|
145 | - ) |
|
146 | - ); |
|
147 | - // add a wildcard recipe for loading core classes |
|
148 | - $this->CoffeeShop->addRecipe( |
|
149 | - new Recipe( |
|
150 | - 'EE_*', |
|
151 | - '', |
|
152 | - array(), |
|
153 | - array(), |
|
154 | - CoffeeMaker::BREW_SHARED, |
|
155 | - array( |
|
156 | - EE_CORE . '*.core.php', |
|
157 | - EE_ADMIN . '*.core.php', |
|
158 | - EE_CPTS . '*.core.php', |
|
159 | - EE_CORE . 'data_migration_scripts/*.core.php', |
|
160 | - ) |
|
161 | - ) |
|
162 | - ); |
|
163 | - // load admin page parent class |
|
164 | - $this->CoffeeShop->addRecipe( |
|
165 | - new Recipe( |
|
166 | - 'EE_Admin_Page*', |
|
167 | - '', |
|
168 | - array(), |
|
169 | - array(), |
|
170 | - CoffeeMaker::BREW_LOAD_ONLY, |
|
171 | - array(EE_ADMIN . '*.core.php') |
|
172 | - ) |
|
173 | - ); |
|
174 | - // add a wildcard recipe for loading core classes |
|
175 | - // $this->CoffeeShop->addRecipe( |
|
176 | - // new Recipe( |
|
177 | - // '*_Admin_Page', |
|
178 | - // '', |
|
179 | - // array(), |
|
180 | - // array(), |
|
181 | - // CoffeeMaker::BREW_SHARED, |
|
182 | - // array( |
|
183 | - // EE_ADMIN_PAGES . 'transactions/*.core.php', |
|
184 | - // ) |
|
185 | - // ) |
|
186 | - // ); |
|
187 | - } |
|
81 | + /** |
|
82 | + * Recipes define how to load legacy classes |
|
83 | + * |
|
84 | + * @throws InvalidIdentifierException |
|
85 | + */ |
|
86 | + public function addRecipes() |
|
87 | + { |
|
88 | + // add default recipe, which should handle loading for most PSR-4 compatible classes |
|
89 | + // as long as they are not type hinting for interfaces |
|
90 | + $this->CoffeeShop->addRecipe( |
|
91 | + new Recipe( |
|
92 | + Recipe::DEFAULT_ID |
|
93 | + ) |
|
94 | + ); |
|
95 | + // PSR-4 compatible class with aliases |
|
96 | + $this->CoffeeShop->addRecipe( |
|
97 | + new Recipe( |
|
98 | + 'CommandHandlerManager', |
|
99 | + 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
100 | + array( |
|
101 | + 'CommandHandlerManagerInterface', |
|
102 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
103 | + ), |
|
104 | + array(), |
|
105 | + CoffeeMaker::BREW_SHARED |
|
106 | + ) |
|
107 | + ); |
|
108 | + // PSR-4 compatible class with aliases, which dependency on CommandHandlerManager |
|
109 | + $this->CoffeeShop->addRecipe( |
|
110 | + new Recipe( |
|
111 | + 'CommandBus', |
|
112 | + 'EventEspresso\core\services\commands\CommandBus', |
|
113 | + array( |
|
114 | + 'CommandBusInterface', |
|
115 | + 'EventEspresso\core\services\commands\CommandBusInterface', |
|
116 | + ), |
|
117 | + array(), |
|
118 | + CoffeeMaker::BREW_SHARED |
|
119 | + ) |
|
120 | + ); |
|
121 | + // LEGACY classes that are NOT compatible with PSR-4 autoloading, and so must specify a filepath |
|
122 | + // add a wildcard recipe for loading legacy core interfaces |
|
123 | + $this->CoffeeShop->addRecipe( |
|
124 | + new Recipe( |
|
125 | + 'EEI_*', |
|
126 | + '', |
|
127 | + array(), |
|
128 | + array(), |
|
129 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
130 | + array( |
|
131 | + EE_INTERFACES . '*.php', |
|
132 | + EE_INTERFACES . '*.interfaces.php', |
|
133 | + ) |
|
134 | + ) |
|
135 | + ); |
|
136 | + // add a wildcard recipe for loading models |
|
137 | + $this->CoffeeShop->addRecipe( |
|
138 | + new Recipe( |
|
139 | + 'EEM_*', |
|
140 | + '', |
|
141 | + array(), |
|
142 | + array(), |
|
143 | + CoffeeMaker::BREW_SHARED, |
|
144 | + EE_MODELS . '*.model.php' |
|
145 | + ) |
|
146 | + ); |
|
147 | + // add a wildcard recipe for loading core classes |
|
148 | + $this->CoffeeShop->addRecipe( |
|
149 | + new Recipe( |
|
150 | + 'EE_*', |
|
151 | + '', |
|
152 | + array(), |
|
153 | + array(), |
|
154 | + CoffeeMaker::BREW_SHARED, |
|
155 | + array( |
|
156 | + EE_CORE . '*.core.php', |
|
157 | + EE_ADMIN . '*.core.php', |
|
158 | + EE_CPTS . '*.core.php', |
|
159 | + EE_CORE . 'data_migration_scripts/*.core.php', |
|
160 | + ) |
|
161 | + ) |
|
162 | + ); |
|
163 | + // load admin page parent class |
|
164 | + $this->CoffeeShop->addRecipe( |
|
165 | + new Recipe( |
|
166 | + 'EE_Admin_Page*', |
|
167 | + '', |
|
168 | + array(), |
|
169 | + array(), |
|
170 | + CoffeeMaker::BREW_LOAD_ONLY, |
|
171 | + array(EE_ADMIN . '*.core.php') |
|
172 | + ) |
|
173 | + ); |
|
174 | + // add a wildcard recipe for loading core classes |
|
175 | + // $this->CoffeeShop->addRecipe( |
|
176 | + // new Recipe( |
|
177 | + // '*_Admin_Page', |
|
178 | + // '', |
|
179 | + // array(), |
|
180 | + // array(), |
|
181 | + // CoffeeMaker::BREW_SHARED, |
|
182 | + // array( |
|
183 | + // EE_ADMIN_PAGES . 'transactions/*.core.php', |
|
184 | + // ) |
|
185 | + // ) |
|
186 | + // ); |
|
187 | + } |
|
188 | 188 | |
189 | 189 | |
190 | - /** |
|
191 | - * bootstrap EE and the request stack |
|
192 | - * |
|
193 | - * @throws ServiceNotFoundException |
|
194 | - * @throws InvalidClassException |
|
195 | - * @throws InvalidDataTypeException |
|
196 | - * @throws InvalidIdentifierException |
|
197 | - * @throws exceptions\ServiceExistsException |
|
198 | - * @throws OutOfBoundsException |
|
199 | - * @throws exceptions\InstantiationException |
|
200 | - */ |
|
201 | - public function firstBrew() |
|
202 | - { |
|
203 | - $this->CoffeeShop->brew( |
|
204 | - 'EventEspresso\core\services\request\Request', |
|
205 | - array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
206 | - ); |
|
207 | - $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
208 | - $this->CoffeeShop->brew('EE_Bootstrap'); |
|
209 | - } |
|
190 | + /** |
|
191 | + * bootstrap EE and the request stack |
|
192 | + * |
|
193 | + * @throws ServiceNotFoundException |
|
194 | + * @throws InvalidClassException |
|
195 | + * @throws InvalidDataTypeException |
|
196 | + * @throws InvalidIdentifierException |
|
197 | + * @throws exceptions\ServiceExistsException |
|
198 | + * @throws OutOfBoundsException |
|
199 | + * @throws exceptions\InstantiationException |
|
200 | + */ |
|
201 | + public function firstBrew() |
|
202 | + { |
|
203 | + $this->CoffeeShop->brew( |
|
204 | + 'EventEspresso\core\services\request\Request', |
|
205 | + array($_GET, $_POST, $_COOKIE, $_SERVER) |
|
206 | + ); |
|
207 | + $this->CoffeeShop->brew('EventEspresso\core\services\request\Response'); |
|
208 | + $this->CoffeeShop->brew('EE_Bootstrap'); |
|
209 | + } |
|
210 | 210 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
27 | 27 | wp_enqueue_style( |
28 | 28 | 'ee_progress_steps_display_number_bubbles', |
29 | - plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
29 | + plugin_dir_url(__FILE__).'number_bubbles.css' |
|
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
@@ -39,6 +39,6 @@ discard block |
||
39 | 39 | public function getTemplate() |
40 | 40 | { |
41 | 41 | // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
42 | - return __DIR__ . '/number_bubbles.template.php'; |
|
42 | + return __DIR__.'/number_bubbles.template.php'; |
|
43 | 43 | } |
44 | 44 | } |
@@ -14,29 +14,29 @@ |
||
14 | 14 | */ |
15 | 15 | class NumberBubblesProgressStepsDisplay implements ProgressStepsDisplayInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * used for setting up css and js required for the display strategy |
|
19 | - * |
|
20 | - * @return void |
|
21 | - */ |
|
22 | - public function enqueueStylesAndScripts() |
|
23 | - { |
|
24 | - // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
|
25 | - wp_enqueue_style( |
|
26 | - 'ee_progress_steps_display_number_bubbles', |
|
27 | - plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
28 | - ); |
|
29 | - } |
|
17 | + /** |
|
18 | + * used for setting up css and js required for the display strategy |
|
19 | + * |
|
20 | + * @return void |
|
21 | + */ |
|
22 | + public function enqueueStylesAndScripts() |
|
23 | + { |
|
24 | + // core/services/progress_steps/display_strategies/number_bubbles/number_bubbles.css |
|
25 | + wp_enqueue_style( |
|
26 | + 'ee_progress_steps_display_number_bubbles', |
|
27 | + plugin_dir_url(__FILE__) . 'number_bubbles.css' |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * loads and returns a full server path to the template used for the display strategy |
|
34 | - * |
|
35 | - * @return string |
|
36 | - */ |
|
37 | - public function getTemplate() |
|
38 | - { |
|
39 | - // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
|
40 | - return __DIR__ . '/number_bubbles.template.php'; |
|
41 | - } |
|
32 | + /** |
|
33 | + * loads and returns a full server path to the template used for the display strategy |
|
34 | + * |
|
35 | + * @return string |
|
36 | + */ |
|
37 | + public function getTemplate() |
|
38 | + { |
|
39 | + // return plugin_dir_path( __FILE__ ) . 'number_bubbles.template.php'; |
|
40 | + return __DIR__ . '/number_bubbles.template.php'; |
|
41 | + } |
|
42 | 42 | } |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public function venue_location($content) |
164 | 164 | { |
165 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
165 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
@@ -177,16 +177,16 @@ discard block |
||
177 | 177 | // get some style |
178 | 178 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
179 | 179 | // first check theme folder |
180 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
180 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
181 | 181 | wp_register_style( |
182 | 182 | $this->theme, |
183 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
183 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
184 | 184 | array('dashicons', 'espresso_default') |
185 | 185 | ); |
186 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
186 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
187 | 187 | wp_register_style( |
188 | 188 | $this->theme, |
189 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
189 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
190 | 190 | array('dashicons', 'espresso_default') |
191 | 191 | ); |
192 | 192 | } |
@@ -29,173 +29,173 @@ |
||
29 | 29 | */ |
30 | 30 | class EED_Venue_Single extends EED_Module |
31 | 31 | { |
32 | - /** |
|
33 | - * @return EED_Venue_Single |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types[EspressoPostType::VENUES]['singular_slug'], |
|
58 | - 'Venue_Single', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance() |
|
100 | - ->load_core('Front_Controller', array(), false, true) |
|
101 | - ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | - ) { |
|
103 | - EEH_Template::load_espresso_theme_functions(); |
|
104 | - // then add extra event data via hooks |
|
105 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | - // don't display entry meta because the existing theme will take car of that |
|
108 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | - } |
|
110 | - return $template; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * the_title |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @param string $title |
|
119 | - * @return string |
|
120 | - */ |
|
121 | - public function the_title($title = '') |
|
122 | - { |
|
123 | - return $title; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * venue_details |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @param string $content |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function venue_details($content) |
|
135 | - { |
|
136 | - global $post; |
|
137 | - if ( |
|
138 | - $post->post_type == EspressoPostType::VENUES |
|
139 | - && ! post_password_required() |
|
140 | - ) { |
|
141 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | - // it uses the_content() for displaying the $post->post_content |
|
143 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | - // add filters we want |
|
147 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | - // now load our template |
|
149 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | - // remove other filters we added so they won't get applied to the next post |
|
151 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | - } |
|
153 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | - return ! empty($template) ? $template : $content; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * venue_location |
|
160 | - * |
|
161 | - * @access public |
|
162 | - * @param string $content |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function venue_location($content) |
|
166 | - { |
|
167 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * wp_enqueue_scripts |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @return void |
|
176 | - */ |
|
177 | - public function wp_enqueue_scripts() |
|
178 | - { |
|
179 | - // get some style |
|
180 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | - // first check theme folder |
|
182 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | - wp_register_style( |
|
184 | - $this->theme, |
|
185 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | - array('dashicons', 'espresso_default') |
|
187 | - ); |
|
188 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | - wp_register_style( |
|
190 | - $this->theme, |
|
191 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | - array('dashicons', 'espresso_default') |
|
193 | - ); |
|
194 | - } |
|
195 | - wp_enqueue_style($this->theme); |
|
196 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venue_Single |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types[EspressoPostType::VENUES]['singular_slug'], |
|
58 | + 'Venue_Single', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance() |
|
100 | + ->load_core('Front_Controller', array(), false, true) |
|
101 | + ->get_selected_template() != 'single-espresso_venues.php' |
|
102 | + ) { |
|
103 | + EEH_Template::load_espresso_theme_functions(); |
|
104 | + // then add extra event data via hooks |
|
105 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
106 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
107 | + // don't display entry meta because the existing theme will take car of that |
|
108 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
109 | + } |
|
110 | + return $template; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * the_title |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @param string $title |
|
119 | + * @return string |
|
120 | + */ |
|
121 | + public function the_title($title = '') |
|
122 | + { |
|
123 | + return $title; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * venue_details |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @param string $content |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function venue_details($content) |
|
135 | + { |
|
136 | + global $post; |
|
137 | + if ( |
|
138 | + $post->post_type == EspressoPostType::VENUES |
|
139 | + && ! post_password_required() |
|
140 | + ) { |
|
141 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
142 | + // it uses the_content() for displaying the $post->post_content |
|
143 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
144 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
145 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
146 | + // add filters we want |
|
147 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
148 | + // now load our template |
|
149 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
150 | + // remove other filters we added so they won't get applied to the next post |
|
151 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
152 | + } |
|
153 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
154 | + return ! empty($template) ? $template : $content; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * venue_location |
|
160 | + * |
|
161 | + * @access public |
|
162 | + * @param string $content |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function venue_location($content) |
|
166 | + { |
|
167 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * wp_enqueue_scripts |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @return void |
|
176 | + */ |
|
177 | + public function wp_enqueue_scripts() |
|
178 | + { |
|
179 | + // get some style |
|
180 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_single()) { |
|
181 | + // first check theme folder |
|
182 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
183 | + wp_register_style( |
|
184 | + $this->theme, |
|
185 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
186 | + array('dashicons', 'espresso_default') |
|
187 | + ); |
|
188 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
189 | + wp_register_style( |
|
190 | + $this->theme, |
|
191 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
192 | + array('dashicons', 'espresso_default') |
|
193 | + ); |
|
194 | + } |
|
195 | + wp_enqueue_style($this->theme); |
|
196 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
197 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | 201 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function venue_location($content) |
172 | 172 | { |
173 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
173 | + return $content.EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | // get some style |
186 | 186 | if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
187 | 187 | // first check theme folder |
188 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
188 | + if (is_readable(get_stylesheet_directory().$this->theme.'/style.css')) { |
|
189 | 189 | wp_register_style( |
190 | 190 | $this->theme, |
191 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
191 | + get_stylesheet_directory_uri().$this->theme.'/style.css', |
|
192 | 192 | array('dashicons', 'espresso_default') |
193 | 193 | ); |
194 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
194 | + } elseif (is_readable(EE_TEMPLATES.$this->theme.'/style.css')) { |
|
195 | 195 | wp_register_style( |
196 | 196 | $this->theme, |
197 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
197 | + EE_TEMPLATES_URL.$this->theme.'/style.css', |
|
198 | 198 | array('dashicons', 'espresso_default') |
199 | 199 | ); |
200 | 200 | } |
@@ -29,178 +29,178 @@ |
||
29 | 29 | */ |
30 | 30 | class EED_Venues_Archive extends EED_Module |
31 | 31 | { |
32 | - /** |
|
33 | - * @return EED_Venues_Archive |
|
34 | - */ |
|
35 | - public static function instance() |
|
36 | - { |
|
37 | - return parent::get_instance(__CLASS__); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | - * |
|
44 | - * @return void |
|
45 | - * @throws InvalidArgumentException |
|
46 | - * @throws InvalidDataTypeException |
|
47 | - * @throws InvalidInterfaceException |
|
48 | - */ |
|
49 | - public static function set_hooks() |
|
50 | - { |
|
51 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | - ); |
|
55 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | - EE_Config::register_route( |
|
57 | - $custom_post_types[EspressoPostType::VENUES]['plural_slug'], |
|
58 | - 'Venues_Archive', |
|
59 | - 'run' |
|
60 | - ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @return void |
|
68 | - */ |
|
69 | - public static function set_hooks_admin() |
|
70 | - { |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * run - initial module setup |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @param \WP $WP |
|
79 | - */ |
|
80 | - public function run($WP) |
|
81 | - { |
|
82 | - // check what template is loaded |
|
83 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * template_include |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @param string $template |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function template_include($template) |
|
96 | - { |
|
97 | - // not a custom template? |
|
98 | - if ( |
|
99 | - EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | - ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | - ) { |
|
102 | - EEH_Template::load_espresso_theme_functions(); |
|
103 | - // then add extra event data via hooks |
|
104 | - add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | - // don't know if theme uses the_excerpt |
|
106 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | - // or the_content |
|
108 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | - // don't display entry meta because the existing theme will take care of that |
|
110 | - add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | - } |
|
112 | - return $template; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * the_title |
|
118 | - * |
|
119 | - * @access public |
|
120 | - * @param string $title |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function the_title($title = '') |
|
124 | - { |
|
125 | - return $title; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - /** |
|
130 | - * venue_details |
|
131 | - * |
|
132 | - * @access public |
|
133 | - * @param string $content |
|
134 | - * @return string |
|
135 | - */ |
|
136 | - public function venue_details($content) |
|
137 | - { |
|
138 | - global $post; |
|
139 | - if ( |
|
140 | - $post->post_type == EspressoPostType::VENUES |
|
141 | - && ! post_password_required() |
|
142 | - ) { |
|
143 | - // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | - // it uses the_content() for displaying the $post->post_content |
|
145 | - // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | - // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | - remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | - remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | - // add filters we want |
|
150 | - add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | - add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | - // now load our template |
|
153 | - $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | - // now add our filter back in, plus some others |
|
155 | - add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | - add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | - // remove other filters we added so they won't get applied to the next post |
|
158 | - remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | - remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | - } |
|
162 | - return ! empty($template) ? $template : $content; |
|
163 | - } |
|
164 | - |
|
165 | - |
|
166 | - /** |
|
167 | - * venue_location |
|
168 | - * |
|
169 | - * @access public |
|
170 | - * @param string $content |
|
171 | - * @return string |
|
172 | - */ |
|
173 | - public function venue_location($content) |
|
174 | - { |
|
175 | - return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | - } |
|
177 | - |
|
178 | - |
|
179 | - /** |
|
180 | - * wp_enqueue_scripts |
|
181 | - * |
|
182 | - * @access public |
|
183 | - * @return void |
|
184 | - */ |
|
185 | - public function wp_enqueue_scripts() |
|
186 | - { |
|
187 | - // get some style |
|
188 | - if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | - // first check theme folder |
|
190 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | - wp_register_style( |
|
192 | - $this->theme, |
|
193 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | - array('dashicons', 'espresso_default') |
|
195 | - ); |
|
196 | - } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | - wp_register_style( |
|
198 | - $this->theme, |
|
199 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | - array('dashicons', 'espresso_default') |
|
201 | - ); |
|
202 | - } |
|
203 | - wp_enqueue_style($this->theme); |
|
204 | - } |
|
205 | - } |
|
32 | + /** |
|
33 | + * @return EED_Venues_Archive |
|
34 | + */ |
|
35 | + public static function instance() |
|
36 | + { |
|
37 | + return parent::get_instance(__CLASS__); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
43 | + * |
|
44 | + * @return void |
|
45 | + * @throws InvalidArgumentException |
|
46 | + * @throws InvalidDataTypeException |
|
47 | + * @throws InvalidInterfaceException |
|
48 | + */ |
|
49 | + public static function set_hooks() |
|
50 | + { |
|
51 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
52 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
53 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
54 | + ); |
|
55 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
56 | + EE_Config::register_route( |
|
57 | + $custom_post_types[EspressoPostType::VENUES]['plural_slug'], |
|
58 | + 'Venues_Archive', |
|
59 | + 'run' |
|
60 | + ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @return void |
|
68 | + */ |
|
69 | + public static function set_hooks_admin() |
|
70 | + { |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * run - initial module setup |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @param \WP $WP |
|
79 | + */ |
|
80 | + public function run($WP) |
|
81 | + { |
|
82 | + // check what template is loaded |
|
83 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
84 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * template_include |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @param string $template |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function template_include($template) |
|
96 | + { |
|
97 | + // not a custom template? |
|
98 | + if ( |
|
99 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true) |
|
100 | + ->get_selected_template() != 'archive-espresso_venues.php' |
|
101 | + ) { |
|
102 | + EEH_Template::load_espresso_theme_functions(); |
|
103 | + // then add extra event data via hooks |
|
104 | + add_filter('the_title', array($this, 'the_title'), 100, 1); |
|
105 | + // don't know if theme uses the_excerpt |
|
106 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
107 | + // or the_content |
|
108 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
109 | + // don't display entry meta because the existing theme will take care of that |
|
110 | + add_filter('FHEE__content_espresso_venues_details_template__display_entry_meta', '__return_false'); |
|
111 | + } |
|
112 | + return $template; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * the_title |
|
118 | + * |
|
119 | + * @access public |
|
120 | + * @param string $title |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function the_title($title = '') |
|
124 | + { |
|
125 | + return $title; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + /** |
|
130 | + * venue_details |
|
131 | + * |
|
132 | + * @access public |
|
133 | + * @param string $content |
|
134 | + * @return string |
|
135 | + */ |
|
136 | + public function venue_details($content) |
|
137 | + { |
|
138 | + global $post; |
|
139 | + if ( |
|
140 | + $post->post_type == EspressoPostType::VENUES |
|
141 | + && ! post_password_required() |
|
142 | + ) { |
|
143 | + // since the 'content-espresso_venues-details.php' template might be used directly from within a theme, |
|
144 | + // it uses the_content() for displaying the $post->post_content |
|
145 | + // so in order to load a template that uses the_content() from within a callback being used to filter the_content(), |
|
146 | + // we need to first remove this callback from being applied to the_content() (otherwise it will recurse and blow up the interweb) |
|
147 | + remove_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
148 | + remove_filter('the_content', array($this, 'venue_details'), 100); |
|
149 | + // add filters we want |
|
150 | + add_filter('the_content', array($this, 'venue_location'), 110); |
|
151 | + add_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
152 | + // now load our template |
|
153 | + $template = EEH_Template::locate_template('content-espresso_venues-details.php'); |
|
154 | + // now add our filter back in, plus some others |
|
155 | + add_filter('the_excerpt', array($this, 'venue_details'), 100); |
|
156 | + add_filter('the_content', array($this, 'venue_details'), 100); |
|
157 | + // remove other filters we added so they won't get applied to the next post |
|
158 | + remove_filter('the_content', array($this, 'venue_location'), 110); |
|
159 | + remove_filter('the_excerpt', array($this, 'venue_location'), 110); |
|
160 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
161 | + } |
|
162 | + return ! empty($template) ? $template : $content; |
|
163 | + } |
|
164 | + |
|
165 | + |
|
166 | + /** |
|
167 | + * venue_location |
|
168 | + * |
|
169 | + * @access public |
|
170 | + * @param string $content |
|
171 | + * @return string |
|
172 | + */ |
|
173 | + public function venue_location($content) |
|
174 | + { |
|
175 | + return $content . EEH_Template::locate_template('content-espresso_venues-location.php'); |
|
176 | + } |
|
177 | + |
|
178 | + |
|
179 | + /** |
|
180 | + * wp_enqueue_scripts |
|
181 | + * |
|
182 | + * @access public |
|
183 | + * @return void |
|
184 | + */ |
|
185 | + public function wp_enqueue_scripts() |
|
186 | + { |
|
187 | + // get some style |
|
188 | + if (apply_filters('FHEE_enable_default_espresso_css', true) && is_archive()) { |
|
189 | + // first check theme folder |
|
190 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
191 | + wp_register_style( |
|
192 | + $this->theme, |
|
193 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
194 | + array('dashicons', 'espresso_default') |
|
195 | + ); |
|
196 | + } elseif (is_readable(EE_TEMPLATES . $this->theme . '/style.css')) { |
|
197 | + wp_register_style( |
|
198 | + $this->theme, |
|
199 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
200 | + array('dashicons', 'espresso_default') |
|
201 | + ); |
|
202 | + } |
|
203 | + wp_enqueue_style($this->theme); |
|
204 | + } |
|
205 | + } |
|
206 | 206 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | { |
80 | 80 | // first get registrations just for this attendee. |
81 | 81 | $att = $data->att_obj; |
82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
83 | 83 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
84 | 84 | ? array($data->reg_obj) : $registrations_on_attendee; |
85 | 85 | $tkts = array(); |
@@ -101,12 +101,12 @@ discard block |
||
101 | 101 | // tickets will be tickets for all registrations on this attendee. |
102 | 102 | foreach ($registrations_on_attendee as $reg) { |
103 | 103 | if ($reg instanceof EE_Registration) { |
104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | - $data->registrations[ $reg->ID() ] |
|
106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | - ) ]['tkt_obj'] : null; |
|
104 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
105 | + $data->registrations[$reg->ID()] |
|
106 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
107 | + )]['tkt_obj'] : null; |
|
108 | 108 | if ($ticket instanceof EE_Ticket) { |
109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
109 | + $tkts[$ticket->ID()] = $ticket; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -123,12 +123,12 @@ discard block |
||
123 | 123 | // data will be tickets for this event for this recipient. |
124 | 124 | foreach ($registrations_on_attendee as $reg) { |
125 | 125 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | - $data->registrations[ $reg->ID() ] |
|
128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | - ) ]['tkt_obj'] : null; |
|
126 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
127 | + $data->registrations[$reg->ID()] |
|
128 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
129 | + )]['tkt_obj'] : null; |
|
130 | 130 | if ($ticket instanceof EE_Ticket) { |
131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
131 | + $tkts[$ticket->ID()] = $ticket; |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | // first get registrations just for this attendee. |
172 | 172 | $att = $data->att_obj; |
173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[$att->ID()]['reg_objs'] : array(); |
|
174 | 174 | $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
175 | 175 | ? array($data->reg_obj) |
176 | 176 | : $registrations_on_attendee; |
@@ -185,14 +185,14 @@ discard block |
||
185 | 185 | // dtts will be datetimes for all registrations on this attendee |
186 | 186 | foreach ($registrations_on_attendee as $reg) { |
187 | 187 | if ($reg instanceof EE_Registration) { |
188 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | - $data->registrations[ $reg->ID() ] |
|
190 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | - ) ]['dtt_objs'] : array(); |
|
188 | + $dtt_objs = isset($data->registrations[$reg->ID()]) && is_array( |
|
189 | + $data->registrations[$reg->ID()] |
|
190 | + ) && isset($data->registrations[$reg->ID()]['dtt_objs']) ? $data->registrations[$reg->ID( |
|
191 | + )]['dtt_objs'] : array(); |
|
192 | 192 | $dtt_objs = (array) $dtt_objs; |
193 | 193 | foreach ($dtt_objs as $dtt_obj) { |
194 | 194 | if ($dtt_obj instanceof EE_Datetime) { |
195 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
195 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
196 | 196 | } |
197 | 197 | } |
198 | 198 | } |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | // data will be datetimes for this event for this recipient |
209 | 209 | foreach ($registrations_on_attendee as $reg) { |
210 | 210 | if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
211 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | - $data->registrations[ $reg->ID() ] |
|
213 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | - ) ]['tkt_obj'] : null; |
|
211 | + $ticket = isset($data->registrations[$reg->ID()]) && is_array( |
|
212 | + $data->registrations[$reg->ID()] |
|
213 | + ) && isset($data->registrations[$reg->ID()]['tkt_obj']) ? $data->registrations[$reg->ID( |
|
214 | + )]['tkt_obj'] : null; |
|
215 | 215 | if ($ticket instanceof EE_Ticket) { |
216 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | - $data->tickets[ $ticket->ID() ] |
|
218 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | - ) ]['dtt_objs'] : array(); |
|
216 | + $dtt_objs = isset($data->tickets[$ticket->ID()]) && is_array( |
|
217 | + $data->tickets[$ticket->ID()] |
|
218 | + ) && isset($data->tickets[$ticket->ID()]['dtt_objs']) ? $data->tickets[$ticket->ID( |
|
219 | + )]['dtt_objs'] : array(); |
|
220 | 220 | $dtt_objs = (array) $dtt_objs; |
221 | 221 | foreach ($dtt_objs as $dtt_obj) { |
222 | 222 | if ($dtt_obj instanceof EE_Datetime) { |
223 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
223 | + $dtts[$dtt_obj->ID()] = $dtt_obj; |
|
224 | 224 | } |
225 | 225 | } |
226 | 226 | } |
@@ -18,225 +18,225 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Recipient_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct(); |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - protected function _init_props() |
|
28 | - { |
|
29 | - $this->label = esc_html__('Recipient List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
31 | - $this->_shortcodes = array( |
|
32 | - '[RECIPIENT_TICKET_LIST]' => esc_html__( |
|
33 | - 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
34 | - 'event_espresso' |
|
35 | - ), |
|
36 | - '[RECIPIENT_DATETIME_LIST]' => esc_html__( |
|
37 | - 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
38 | - 'event_espresso' |
|
39 | - ), |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - protected function _parser($shortcode) |
|
45 | - { |
|
46 | - switch ($shortcode) { |
|
47 | - case '[RECIPIENT_TICKET_LIST]': |
|
48 | - return $this->_get_recipient_ticket_list(); |
|
49 | - break; |
|
50 | - |
|
51 | - case '[RECIPIENT_DATETIME_LIST]': |
|
52 | - return $this->_get_recipient_datetime_list(); |
|
53 | - break; |
|
54 | - } |
|
55 | - return ''; |
|
56 | - } |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
61 | - * |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - private function _get_recipient_ticket_list() |
|
65 | - { |
|
66 | - $this->_validate_list_requirements(); |
|
67 | - |
|
68 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
69 | - return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
70 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | - return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
72 | - } else { |
|
73 | - return ''; |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
79 | - { |
|
80 | - // first get registrations just for this attendee. |
|
81 | - $att = $data->att_obj; |
|
82 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
83 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
84 | - ? array($data->reg_obj) : $registrations_on_attendee; |
|
85 | - $tkts = array(); |
|
86 | - |
|
87 | - // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
88 | - // which means we want to get tickets for all events this addressee is a part of. |
|
89 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
90 | - $valid_shortcodes = array( |
|
91 | - 'ticket', |
|
92 | - 'event_list', |
|
93 | - 'attendee_list', |
|
94 | - 'datetime_list', |
|
95 | - 'registration_details', |
|
96 | - 'attendee', |
|
97 | - 'recipient_details', |
|
98 | - ); |
|
99 | - $template = $this->_data['template']; |
|
100 | - |
|
101 | - // tickets will be tickets for all registrations on this attendee. |
|
102 | - foreach ($registrations_on_attendee as $reg) { |
|
103 | - if ($reg instanceof EE_Registration) { |
|
104 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | - $data->registrations[ $reg->ID() ] |
|
106 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | - ) ]['tkt_obj'] : null; |
|
108 | - if ($ticket instanceof EE_Ticket) { |
|
109 | - $tkts[ $ticket->ID() ] = $ticket; |
|
110 | - } |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
116 | - $event = $this->_data['data']; |
|
117 | - if ($event instanceof EE_Event) { |
|
118 | - $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
119 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
120 | - ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
121 | - // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
122 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
123 | - // data will be tickets for this event for this recipient. |
|
124 | - foreach ($registrations_on_attendee as $reg) { |
|
125 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
126 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | - $data->registrations[ $reg->ID() ] |
|
128 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | - ) ]['tkt_obj'] : null; |
|
130 | - if ($ticket instanceof EE_Ticket) { |
|
131 | - $tkts[ $ticket->ID() ] = $ticket; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - $tkt_parsed = ''; |
|
138 | - foreach ($tkts as $ticket) { |
|
139 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | - $template, |
|
141 | - $ticket, |
|
142 | - $valid_shortcodes, |
|
143 | - $this->_extra_data |
|
144 | - ); |
|
145 | - } |
|
146 | - return $tkt_parsed; |
|
147 | - } |
|
148 | - |
|
149 | - |
|
150 | - /** |
|
151 | - * figure out what the incoming data is and then return the appropriate parsed value |
|
152 | - * |
|
153 | - * @return string |
|
154 | - */ |
|
155 | - private function _get_recipient_datetime_list() |
|
156 | - { |
|
157 | - $this->_validate_list_requirements(); |
|
158 | - |
|
159 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
160 | - return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
161 | - } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
162 | - return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
163 | - } else { |
|
164 | - return ''; |
|
165 | - } |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
170 | - { |
|
171 | - // first get registrations just for this attendee. |
|
172 | - $att = $data->att_obj; |
|
173 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
174 | - $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
175 | - ? array($data->reg_obj) |
|
176 | - : $registrations_on_attendee; |
|
177 | - $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
178 | - $template = ''; |
|
179 | - $dtts = array(); |
|
180 | - |
|
181 | - // setup valid shortcodes depending on what the status of the $this->_data property is |
|
182 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
183 | - $template = $this->_data['template']; |
|
184 | - |
|
185 | - // dtts will be datetimes for all registrations on this attendee |
|
186 | - foreach ($registrations_on_attendee as $reg) { |
|
187 | - if ($reg instanceof EE_Registration) { |
|
188 | - $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | - $data->registrations[ $reg->ID() ] |
|
190 | - ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | - ) ]['dtt_objs'] : array(); |
|
192 | - $dtt_objs = (array) $dtt_objs; |
|
193 | - foreach ($dtt_objs as $dtt_obj) { |
|
194 | - if ($dtt_obj instanceof EE_Datetime) { |
|
195 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
200 | - } |
|
201 | - |
|
202 | - // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
203 | - $event = $this->_data['data']; |
|
204 | - if ($event instanceof EE_Event) { |
|
205 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
206 | - ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
207 | - |
|
208 | - // data will be datetimes for this event for this recipient |
|
209 | - foreach ($registrations_on_attendee as $reg) { |
|
210 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
211 | - $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | - $data->registrations[ $reg->ID() ] |
|
213 | - ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | - ) ]['tkt_obj'] : null; |
|
215 | - if ($ticket instanceof EE_Ticket) { |
|
216 | - $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | - $data->tickets[ $ticket->ID() ] |
|
218 | - ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | - ) ]['dtt_objs'] : array(); |
|
220 | - $dtt_objs = (array) $dtt_objs; |
|
221 | - foreach ($dtt_objs as $dtt_obj) { |
|
222 | - if ($dtt_obj instanceof EE_Datetime) { |
|
223 | - $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
224 | - } |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
228 | - } |
|
229 | - } |
|
230 | - |
|
231 | - $dtt_parsed = ''; |
|
232 | - foreach ($dtts as $datetime) { |
|
233 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
234 | - $template, |
|
235 | - $datetime, |
|
236 | - $valid_shortcodes, |
|
237 | - $this->_extra_data |
|
238 | - ); |
|
239 | - } |
|
240 | - return $dtt_parsed; |
|
241 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Recipient List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to registrant recipients list type data.', 'event_espresso'); |
|
31 | + $this->_shortcodes = array( |
|
32 | + '[RECIPIENT_TICKET_LIST]' => esc_html__( |
|
33 | + 'Will output a list of tickets for the recipient of the email. Note, if the recipient is the Event Author, then this is blank.', |
|
34 | + 'event_espresso' |
|
35 | + ), |
|
36 | + '[RECIPIENT_DATETIME_LIST]' => esc_html__( |
|
37 | + 'Will output a list of datetimes that the person receiving this message has been registered for.', |
|
38 | + 'event_espresso' |
|
39 | + ), |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + protected function _parser($shortcode) |
|
45 | + { |
|
46 | + switch ($shortcode) { |
|
47 | + case '[RECIPIENT_TICKET_LIST]': |
|
48 | + return $this->_get_recipient_ticket_list(); |
|
49 | + break; |
|
50 | + |
|
51 | + case '[RECIPIENT_DATETIME_LIST]': |
|
52 | + return $this->_get_recipient_datetime_list(); |
|
53 | + break; |
|
54 | + } |
|
55 | + return ''; |
|
56 | + } |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
61 | + * |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + private function _get_recipient_ticket_list() |
|
65 | + { |
|
66 | + $this->_validate_list_requirements(); |
|
67 | + |
|
68 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
69 | + return $this->_get_recipient_ticket_list_parsed($this->_data['data']); |
|
70 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
71 | + return $this->_get_recipient_ticket_list_parsed($this->_extra_data['data']); |
|
72 | + } else { |
|
73 | + return ''; |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + private function _get_recipient_ticket_list_parsed(EE_Messages_Addressee $data) |
|
79 | + { |
|
80 | + // first get registrations just for this attendee. |
|
81 | + $att = $data->att_obj; |
|
82 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
83 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
84 | + ? array($data->reg_obj) : $registrations_on_attendee; |
|
85 | + $tkts = array(); |
|
86 | + |
|
87 | + // if we're coming in from the main content then $this->_data['data'] is instanceof EE_Messages_Addressee. |
|
88 | + // which means we want to get tickets for all events this addressee is a part of. |
|
89 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
90 | + $valid_shortcodes = array( |
|
91 | + 'ticket', |
|
92 | + 'event_list', |
|
93 | + 'attendee_list', |
|
94 | + 'datetime_list', |
|
95 | + 'registration_details', |
|
96 | + 'attendee', |
|
97 | + 'recipient_details', |
|
98 | + ); |
|
99 | + $template = $this->_data['template']; |
|
100 | + |
|
101 | + // tickets will be tickets for all registrations on this attendee. |
|
102 | + foreach ($registrations_on_attendee as $reg) { |
|
103 | + if ($reg instanceof EE_Registration) { |
|
104 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
105 | + $data->registrations[ $reg->ID() ] |
|
106 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
107 | + ) ]['tkt_obj'] : null; |
|
108 | + if ($ticket instanceof EE_Ticket) { |
|
109 | + $tkts[ $ticket->ID() ] = $ticket; |
|
110 | + } |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + // if coming from the context of the event list parser, then let's return just the tickets for that event. |
|
116 | + $event = $this->_data['data']; |
|
117 | + if ($event instanceof EE_Event) { |
|
118 | + $valid_shortcodes = array('ticket', 'attendee_list', 'datetime_list', 'attendee', 'recipient_details'); |
|
119 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
120 | + ? $this->_data['template']['ticket_list'] : $this->_extra_data['template']['ticket_list']; |
|
121 | + // let's remove any existing [EVENT_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
122 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
123 | + // data will be tickets for this event for this recipient. |
|
124 | + foreach ($registrations_on_attendee as $reg) { |
|
125 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
126 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
127 | + $data->registrations[ $reg->ID() ] |
|
128 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
129 | + ) ]['tkt_obj'] : null; |
|
130 | + if ($ticket instanceof EE_Ticket) { |
|
131 | + $tkts[ $ticket->ID() ] = $ticket; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + $tkt_parsed = ''; |
|
138 | + foreach ($tkts as $ticket) { |
|
139 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
140 | + $template, |
|
141 | + $ticket, |
|
142 | + $valid_shortcodes, |
|
143 | + $this->_extra_data |
|
144 | + ); |
|
145 | + } |
|
146 | + return $tkt_parsed; |
|
147 | + } |
|
148 | + |
|
149 | + |
|
150 | + /** |
|
151 | + * figure out what the incoming data is and then return the appropriate parsed value |
|
152 | + * |
|
153 | + * @return string |
|
154 | + */ |
|
155 | + private function _get_recipient_datetime_list() |
|
156 | + { |
|
157 | + $this->_validate_list_requirements(); |
|
158 | + |
|
159 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
160 | + return $this->_get_recipient_datetime_list_parsed($this->_data['data']); |
|
161 | + } elseif ($this->_extra_data['data'] instanceof EE_Messages_Addressee) { |
|
162 | + return $this->_get_recipient_datetime_list_parsed($this->_extra_data['data']); |
|
163 | + } else { |
|
164 | + return ''; |
|
165 | + } |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + private function _get_recipient_datetime_list_parsed(EE_Messages_Addressee $data) |
|
170 | + { |
|
171 | + // first get registrations just for this attendee. |
|
172 | + $att = $data->att_obj; |
|
173 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $data->attendees[ $att->ID() ]['reg_objs'] : array(); |
|
174 | + $registrations_on_attendee = empty($registrations_on_attendee) && $data->reg_obj instanceof EE_Registration |
|
175 | + ? array($data->reg_obj) |
|
176 | + : $registrations_on_attendee; |
|
177 | + $valid_shortcodes = array('datetime', 'attendee', 'recipient_details'); |
|
178 | + $template = ''; |
|
179 | + $dtts = array(); |
|
180 | + |
|
181 | + // setup valid shortcodes depending on what the status of the $this->_data property is |
|
182 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
183 | + $template = $this->_data['template']; |
|
184 | + |
|
185 | + // dtts will be datetimes for all registrations on this attendee |
|
186 | + foreach ($registrations_on_attendee as $reg) { |
|
187 | + if ($reg instanceof EE_Registration) { |
|
188 | + $dtt_objs = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
189 | + $data->registrations[ $reg->ID() ] |
|
190 | + ) && isset($data->registrations[ $reg->ID() ]['dtt_objs']) ? $data->registrations[ $reg->ID( |
|
191 | + ) ]['dtt_objs'] : array(); |
|
192 | + $dtt_objs = (array) $dtt_objs; |
|
193 | + foreach ($dtt_objs as $dtt_obj) { |
|
194 | + if ($dtt_obj instanceof EE_Datetime) { |
|
195 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | + } |
|
201 | + |
|
202 | + // if coming from the context of the event list parser, then let's just return the datetimes for the specific event. |
|
203 | + $event = $this->_data['data']; |
|
204 | + if ($event instanceof EE_Event) { |
|
205 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
206 | + ? $this->_data['template']['datetime_list'] : $this->_extra_data['template']['datetime_list']; |
|
207 | + |
|
208 | + // data will be datetimes for this event for this recipient |
|
209 | + foreach ($registrations_on_attendee as $reg) { |
|
210 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
211 | + $ticket = isset($data->registrations[ $reg->ID() ]) && is_array( |
|
212 | + $data->registrations[ $reg->ID() ] |
|
213 | + ) && isset($data->registrations[ $reg->ID() ]['tkt_obj']) ? $data->registrations[ $reg->ID( |
|
214 | + ) ]['tkt_obj'] : null; |
|
215 | + if ($ticket instanceof EE_Ticket) { |
|
216 | + $dtt_objs = isset($data->tickets[ $ticket->ID() ]) && is_array( |
|
217 | + $data->tickets[ $ticket->ID() ] |
|
218 | + ) && isset($data->tickets[ $ticket->ID() ]['dtt_objs']) ? $data->tickets[ $ticket->ID( |
|
219 | + ) ]['dtt_objs'] : array(); |
|
220 | + $dtt_objs = (array) $dtt_objs; |
|
221 | + foreach ($dtt_objs as $dtt_obj) { |
|
222 | + if ($dtt_obj instanceof EE_Datetime) { |
|
223 | + $dtts[ $dtt_obj->ID() ] = $dtt_obj; |
|
224 | + } |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | + } |
|
229 | + } |
|
230 | + |
|
231 | + $dtt_parsed = ''; |
|
232 | + foreach ($dtts as $datetime) { |
|
233 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
234 | + $template, |
|
235 | + $datetime, |
|
236 | + $valid_shortcodes, |
|
237 | + $this->_extra_data |
|
238 | + ); |
|
239 | + } |
|
240 | + return $dtt_parsed; |
|
241 | + } |
|
242 | 242 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $jsonDates = []; |
38 | 38 | foreach ($datetimes as $datetime) { |
39 | 39 | if ($datetime instanceof EE_Datetime) { |
40 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | + $jsonDates[$datetime->ID()] = $this->convertAndEncode($datetime); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | return $jsonDates; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $arrayOfDates = []; |
76 | 76 | foreach ($datetimes as $datetime) { |
77 | 77 | if ($datetime instanceof EE_Datetime) { |
78 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | + $arrayOfDates[$datetime->ID()] = $this->convert($datetime); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | return $arrayOfDates; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $jsonDates = []; |
128 | 128 | foreach ($datetimes as $datetime) { |
129 | 129 | if ($datetime instanceof EE_Datetime) { |
130 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | + $jsonDates[$datetime->ID()] = $this->encode($datetime); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | return $jsonDates; |
@@ -21,125 +21,125 @@ |
||
21 | 21 | */ |
22 | 22 | class DatetimeToJson implements ModelObjectToJsonConverterInterface |
23 | 23 | { |
24 | - /** |
|
25 | - * @param EE_Datetime[] $datetimes |
|
26 | - * @return array |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - * @since 5.0.0.p |
|
33 | - */ |
|
34 | - public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | - { |
|
36 | - $jsonDates = []; |
|
37 | - foreach ($datetimes as $datetime) { |
|
38 | - if ($datetime instanceof EE_Datetime) { |
|
39 | - $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | - } |
|
41 | - } |
|
42 | - return $jsonDates; |
|
43 | - } |
|
24 | + /** |
|
25 | + * @param EE_Datetime[] $datetimes |
|
26 | + * @return array |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + * @since 5.0.0.p |
|
33 | + */ |
|
34 | + public function convertAndEncodeArrayOf(array $datetimes) |
|
35 | + { |
|
36 | + $jsonDates = []; |
|
37 | + foreach ($datetimes as $datetime) { |
|
38 | + if ($datetime instanceof EE_Datetime) { |
|
39 | + $jsonDates[ $datetime->ID() ] = $this->convertAndEncode($datetime); |
|
40 | + } |
|
41 | + } |
|
42 | + return $jsonDates; |
|
43 | + } |
|
44 | 44 | |
45 | 45 | |
46 | - /** |
|
47 | - * @param EE_Datetime $datetime |
|
48 | - * @return false|string |
|
49 | - * @throws EE_Error |
|
50 | - * @throws InvalidArgumentException |
|
51 | - * @throws InvalidDataTypeException |
|
52 | - * @throws InvalidInterfaceException |
|
53 | - * @throws ReflectionException |
|
54 | - * @since 5.0.0.p |
|
55 | - */ |
|
56 | - public function convertAndEncode($datetime) |
|
57 | - { |
|
58 | - return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | - } |
|
46 | + /** |
|
47 | + * @param EE_Datetime $datetime |
|
48 | + * @return false|string |
|
49 | + * @throws EE_Error |
|
50 | + * @throws InvalidArgumentException |
|
51 | + * @throws InvalidDataTypeException |
|
52 | + * @throws InvalidInterfaceException |
|
53 | + * @throws ReflectionException |
|
54 | + * @since 5.0.0.p |
|
55 | + */ |
|
56 | + public function convertAndEncode($datetime) |
|
57 | + { |
|
58 | + return $datetime instanceof EE_Datetime ? $this->encode($this->convert($datetime)) : false; |
|
59 | + } |
|
60 | 60 | |
61 | 61 | |
62 | - /** |
|
63 | - * @param EE_Datetime[] $datetimes |
|
64 | - * @return array |
|
65 | - * @throws EE_Error |
|
66 | - * @throws InvalidArgumentException |
|
67 | - * @throws InvalidDataTypeException |
|
68 | - * @throws InvalidInterfaceException |
|
69 | - * @throws ReflectionException |
|
70 | - * @since 5.0.0.p |
|
71 | - */ |
|
72 | - public function convertArrayOf(array $datetimes) |
|
73 | - { |
|
74 | - $arrayOfDates = []; |
|
75 | - foreach ($datetimes as $datetime) { |
|
76 | - if ($datetime instanceof EE_Datetime) { |
|
77 | - $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | - } |
|
79 | - } |
|
80 | - return $arrayOfDates; |
|
81 | - } |
|
62 | + /** |
|
63 | + * @param EE_Datetime[] $datetimes |
|
64 | + * @return array |
|
65 | + * @throws EE_Error |
|
66 | + * @throws InvalidArgumentException |
|
67 | + * @throws InvalidDataTypeException |
|
68 | + * @throws InvalidInterfaceException |
|
69 | + * @throws ReflectionException |
|
70 | + * @since 5.0.0.p |
|
71 | + */ |
|
72 | + public function convertArrayOf(array $datetimes) |
|
73 | + { |
|
74 | + $arrayOfDates = []; |
|
75 | + foreach ($datetimes as $datetime) { |
|
76 | + if ($datetime instanceof EE_Datetime) { |
|
77 | + $arrayOfDates[ $datetime->ID() ] = $this->convert($datetime); |
|
78 | + } |
|
79 | + } |
|
80 | + return $arrayOfDates; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - /** |
|
85 | - * @param EE_Datetime $datetime |
|
86 | - * @return array |
|
87 | - * @throws EE_Error |
|
88 | - * @throws InvalidDataTypeException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @throws InvalidArgumentException |
|
91 | - * @throws ReflectionException |
|
92 | - * @since 5.0.0.p |
|
93 | - */ |
|
94 | - public function convert($datetime) |
|
95 | - { |
|
96 | - return $datetime instanceof EE_Datetime ? [ |
|
97 | - 'DTT_ID' => $datetime->ID(), |
|
98 | - 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | - 'DTT_name' => $datetime->name(), |
|
100 | - 'DTT_description' => $datetime->description(), |
|
101 | - 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | - 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | - 'DTT_sold' => $datetime->sold(), |
|
104 | - 'DTT_reserved' => $datetime->reserved(), |
|
105 | - 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | - 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | - 'DTT_order' => $datetime->order(), |
|
108 | - 'DTT_parent' => $datetime->parent(), |
|
109 | - 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | - ] : []; |
|
111 | - } |
|
84 | + /** |
|
85 | + * @param EE_Datetime $datetime |
|
86 | + * @return array |
|
87 | + * @throws EE_Error |
|
88 | + * @throws InvalidDataTypeException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @throws InvalidArgumentException |
|
91 | + * @throws ReflectionException |
|
92 | + * @since 5.0.0.p |
|
93 | + */ |
|
94 | + public function convert($datetime) |
|
95 | + { |
|
96 | + return $datetime instanceof EE_Datetime ? [ |
|
97 | + 'DTT_ID' => $datetime->ID(), |
|
98 | + 'EVT_ID' => $datetime->event() instanceof EE_Event ? $datetime->event()->ID() : 0, |
|
99 | + 'DTT_name' => $datetime->name(), |
|
100 | + 'DTT_description' => $datetime->description(), |
|
101 | + 'DTT_EVT_start' => $datetime->start_date(DATE_ATOM), |
|
102 | + 'DTT_EVT_end' => $datetime->end_date(DATE_ATOM), |
|
103 | + 'DTT_sold' => $datetime->sold(), |
|
104 | + 'DTT_reserved' => $datetime->reserved(), |
|
105 | + 'DTT_reg_limit' => $datetime->reg_limit() === INF ? -1 : $datetime->reg_limit(), |
|
106 | + 'DTT_is_primary' => $datetime->get_active_status(), |
|
107 | + 'DTT_order' => $datetime->order(), |
|
108 | + 'DTT_parent' => $datetime->parent(), |
|
109 | + 'DTT_deleted' => $datetime->get('DTT_deleted'), |
|
110 | + ] : []; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * @param EE_Datetime[] $datetimes |
|
116 | - * @return array |
|
117 | - * @throws EE_Error |
|
118 | - * @throws InvalidArgumentException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidInterfaceException |
|
121 | - * @throws ReflectionException |
|
122 | - * @since 5.0.0.p |
|
123 | - */ |
|
124 | - public function encodeArrayOf(array $datetimes) |
|
125 | - { |
|
126 | - $jsonDates = []; |
|
127 | - foreach ($datetimes as $datetime) { |
|
128 | - if ($datetime instanceof EE_Datetime) { |
|
129 | - $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | - } |
|
131 | - } |
|
132 | - return $jsonDates; |
|
133 | - } |
|
114 | + /** |
|
115 | + * @param EE_Datetime[] $datetimes |
|
116 | + * @return array |
|
117 | + * @throws EE_Error |
|
118 | + * @throws InvalidArgumentException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidInterfaceException |
|
121 | + * @throws ReflectionException |
|
122 | + * @since 5.0.0.p |
|
123 | + */ |
|
124 | + public function encodeArrayOf(array $datetimes) |
|
125 | + { |
|
126 | + $jsonDates = []; |
|
127 | + foreach ($datetimes as $datetime) { |
|
128 | + if ($datetime instanceof EE_Datetime) { |
|
129 | + $jsonDates[ $datetime->ID() ] = $this->encode($datetime); |
|
130 | + } |
|
131 | + } |
|
132 | + return $jsonDates; |
|
133 | + } |
|
134 | 134 | |
135 | 135 | |
136 | - /** |
|
137 | - * @param array $datetime_array |
|
138 | - * @return false|string |
|
139 | - * @since 5.0.0.p |
|
140 | - */ |
|
141 | - public function encode(array $datetime_array) |
|
142 | - { |
|
143 | - return wp_json_encode($datetime_array); |
|
144 | - } |
|
136 | + /** |
|
137 | + * @param array $datetime_array |
|
138 | + * @return false|string |
|
139 | + * @since 5.0.0.p |
|
140 | + */ |
|
141 | + public function encode(array $datetime_array) |
|
142 | + { |
|
143 | + return wp_json_encode($datetime_array); |
|
144 | + } |
|
145 | 145 | } |