@@ -23,109 +23,109 @@ |
||
23 | 23 | */ |
24 | 24 | class AddonManager |
25 | 25 | { |
26 | - /** |
|
27 | - * @var AddonCollection |
|
28 | - */ |
|
29 | - private $addons; |
|
26 | + /** |
|
27 | + * @var AddonCollection |
|
28 | + */ |
|
29 | + private $addons; |
|
30 | 30 | |
31 | - /** |
|
32 | - * @var IncompatibleAddonHandler |
|
33 | - */ |
|
34 | - private $incompatible_addon_handler; |
|
31 | + /** |
|
32 | + * @var IncompatibleAddonHandler |
|
33 | + */ |
|
34 | + private $incompatible_addon_handler; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var Psr4Autoloader |
|
38 | - */ |
|
39 | - private $psr4_loader; |
|
36 | + /** |
|
37 | + * @var Psr4Autoloader |
|
38 | + */ |
|
39 | + private $psr4_loader; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var RegisterV1Addon |
|
43 | - */ |
|
44 | - private $register_v1_addon; |
|
41 | + /** |
|
42 | + * @var RegisterV1Addon |
|
43 | + */ |
|
44 | + private $register_v1_addon; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @var ThirdPartyPluginHandler |
|
48 | - */ |
|
49 | - private $third_party_plugin_handler; |
|
46 | + /** |
|
47 | + * @var ThirdPartyPluginHandler |
|
48 | + */ |
|
49 | + private $third_party_plugin_handler; |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * AddonManager constructor. |
|
54 | - * |
|
55 | - * @param AddonCollection $addons |
|
56 | - * @param Psr4Autoloader $psr4_loader |
|
57 | - * @param RegisterV1Addon $register_v1_addon |
|
58 | - * @param IncompatibleAddonHandler $incompatible_addon_handler |
|
59 | - * @param ThirdPartyPluginHandler $third_party_plugin_handler |
|
60 | - */ |
|
61 | - public function __construct( |
|
62 | - AddonCollection $addons, |
|
63 | - Psr4Autoloader $psr4_loader, |
|
64 | - RegisterV1Addon $register_v1_addon, |
|
65 | - IncompatibleAddonHandler $incompatible_addon_handler, |
|
66 | - ThirdPartyPluginHandler $third_party_plugin_handler |
|
67 | - ) { |
|
68 | - $this->addons = $addons; |
|
69 | - $this->psr4_loader = $psr4_loader; |
|
70 | - $this->register_v1_addon = $register_v1_addon; |
|
71 | - $this->incompatible_addon_handler = $incompatible_addon_handler; |
|
72 | - $this->third_party_plugin_handler = $third_party_plugin_handler; |
|
73 | - } |
|
52 | + /** |
|
53 | + * AddonManager constructor. |
|
54 | + * |
|
55 | + * @param AddonCollection $addons |
|
56 | + * @param Psr4Autoloader $psr4_loader |
|
57 | + * @param RegisterV1Addon $register_v1_addon |
|
58 | + * @param IncompatibleAddonHandler $incompatible_addon_handler |
|
59 | + * @param ThirdPartyPluginHandler $third_party_plugin_handler |
|
60 | + */ |
|
61 | + public function __construct( |
|
62 | + AddonCollection $addons, |
|
63 | + Psr4Autoloader $psr4_loader, |
|
64 | + RegisterV1Addon $register_v1_addon, |
|
65 | + IncompatibleAddonHandler $incompatible_addon_handler, |
|
66 | + ThirdPartyPluginHandler $third_party_plugin_handler |
|
67 | + ) { |
|
68 | + $this->addons = $addons; |
|
69 | + $this->psr4_loader = $psr4_loader; |
|
70 | + $this->register_v1_addon = $register_v1_addon; |
|
71 | + $this->incompatible_addon_handler = $incompatible_addon_handler; |
|
72 | + $this->third_party_plugin_handler = $third_party_plugin_handler; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * @throws Exception |
|
78 | - */ |
|
79 | - public function initialize() |
|
80 | - { |
|
81 | - // set autoloaders for all of the classes implementing the legacy EEI_Plugin_API |
|
82 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
83 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
84 | - } |
|
76 | + /** |
|
77 | + * @throws Exception |
|
78 | + */ |
|
79 | + public function initialize() |
|
80 | + { |
|
81 | + // set autoloaders for all of the classes implementing the legacy EEI_Plugin_API |
|
82 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
83 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
84 | + } |
|
85 | 85 | |
86 | 86 | |
87 | - /** |
|
88 | - * @throws Exception |
|
89 | - */ |
|
90 | - public function loadAddons() |
|
91 | - { |
|
92 | - try { |
|
93 | - $this->incompatible_addon_handler->deactivateIncompatibleAddons(); |
|
94 | - // legacy add-on API |
|
95 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
96 | - // new add-on API that uses versioning |
|
97 | - do_action( |
|
98 | - 'AHEE__EventEspresso_core_services_addon_AddonManager__initialize__addons', |
|
99 | - $this->addons, |
|
100 | - espresso_version() |
|
101 | - ); |
|
102 | - // addons are responsible for loading their AddonApiVersion into the AddonCollection |
|
103 | - foreach ($this->addons as $addon) { |
|
104 | - if ($addon instanceof AddonApiVersion) { |
|
105 | - $this->registerAddon($addon); |
|
106 | - } |
|
107 | - } |
|
108 | - $this->third_party_plugin_handler->loadPlugins(); |
|
109 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
110 | - } catch (Exception $exception) { |
|
111 | - new ExceptionStackTraceDisplay($exception); |
|
112 | - } |
|
113 | - } |
|
87 | + /** |
|
88 | + * @throws Exception |
|
89 | + */ |
|
90 | + public function loadAddons() |
|
91 | + { |
|
92 | + try { |
|
93 | + $this->incompatible_addon_handler->deactivateIncompatibleAddons(); |
|
94 | + // legacy add-on API |
|
95 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
96 | + // new add-on API that uses versioning |
|
97 | + do_action( |
|
98 | + 'AHEE__EventEspresso_core_services_addon_AddonManager__initialize__addons', |
|
99 | + $this->addons, |
|
100 | + espresso_version() |
|
101 | + ); |
|
102 | + // addons are responsible for loading their AddonApiVersion into the AddonCollection |
|
103 | + foreach ($this->addons as $addon) { |
|
104 | + if ($addon instanceof AddonApiVersion) { |
|
105 | + $this->registerAddon($addon); |
|
106 | + } |
|
107 | + } |
|
108 | + $this->third_party_plugin_handler->loadPlugins(); |
|
109 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
110 | + } catch (Exception $exception) { |
|
111 | + new ExceptionStackTraceDisplay($exception); |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | 115 | |
116 | - /** |
|
117 | - * @param AddonApiVersion $addon |
|
118 | - * @throws EE_Error |
|
119 | - */ |
|
120 | - private function registerAddon(AddonApiVersion $addon) |
|
121 | - { |
|
122 | - // first register addon namespace so that FQCNs resolve correctly |
|
123 | - $this->psr4_loader->addNamespace($addon->getNamespace(), dirname($addon->mainFile()) . '/src/'); |
|
124 | - // then allow add-on to perform any other setup that relied on PSR4 autoloading |
|
125 | - $addon->initialize(); |
|
126 | - // now register each addon based on it's API version |
|
127 | - if ($addon instanceof AddonApiV1) { |
|
128 | - $this->register_v1_addon->register($addon); |
|
129 | - } |
|
130 | - } |
|
116 | + /** |
|
117 | + * @param AddonApiVersion $addon |
|
118 | + * @throws EE_Error |
|
119 | + */ |
|
120 | + private function registerAddon(AddonApiVersion $addon) |
|
121 | + { |
|
122 | + // first register addon namespace so that FQCNs resolve correctly |
|
123 | + $this->psr4_loader->addNamespace($addon->getNamespace(), dirname($addon->mainFile()) . '/src/'); |
|
124 | + // then allow add-on to perform any other setup that relied on PSR4 autoloading |
|
125 | + $addon->initialize(); |
|
126 | + // now register each addon based on it's API version |
|
127 | + if ($addon instanceof AddonApiV1) { |
|
128 | + $this->register_v1_addon->register($addon); |
|
129 | + } |
|
130 | + } |
|
131 | 131 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | // set autoloaders for all of the classes implementing the legacy EEI_Plugin_API |
82 | 82 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
83 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
83 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | private function registerAddon(AddonApiVersion $addon) |
121 | 121 | { |
122 | 122 | // first register addon namespace so that FQCNs resolve correctly |
123 | - $this->psr4_loader->addNamespace($addon->getNamespace(), dirname($addon->mainFile()) . '/src/'); |
|
123 | + $this->psr4_loader->addNamespace($addon->getNamespace(), dirname($addon->mainFile()).'/src/'); |
|
124 | 124 | // then allow add-on to perform any other setup that relied on PSR4 autoloading |
125 | 125 | $addon->initialize(); |
126 | 126 | // now register each addon based on it's API version |
@@ -42,7 +42,7 @@ |
||
42 | 42 | && ! function_exists('json_basic_auth_handler') |
43 | 43 | && ! function_exists('json_basic_auth_error') |
44 | 44 | ) { |
45 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
45 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth/basic-auth.php'; |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |
@@ -7,43 +7,43 @@ |
||
7 | 7 | class ThirdPartyPluginHandler |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @var RequestInterface $request |
|
12 | - */ |
|
13 | - private $request; |
|
14 | - |
|
15 | - |
|
16 | - /** |
|
17 | - * ThirdPartyPluginHandler constructor. |
|
18 | - * |
|
19 | - * @param RequestInterface $request |
|
20 | - */ |
|
21 | - public function __construct(RequestInterface $request) |
|
22 | - { |
|
23 | - $this->request = $request; |
|
24 | - } |
|
25 | - |
|
26 | - |
|
27 | - public function loadPlugins() |
|
28 | - { |
|
29 | - $this->wpApiBasicAuth(); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - private function wpApiBasicAuth() |
|
34 | - { |
|
35 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
36 | - // We want it for mobile apps. Just include the entire plugin |
|
37 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
38 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
39 | - // and causes a fatal error |
|
40 | - if ( |
|
41 | - ($this->request->isWordPressApi() || $this->request->isApi()) |
|
42 | - && ! $this->request->isActivation() |
|
43 | - && ! function_exists('json_basic_auth_handler') |
|
44 | - && ! function_exists('json_basic_auth_error') |
|
45 | - ) { |
|
46 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
47 | - } |
|
48 | - } |
|
10 | + /** |
|
11 | + * @var RequestInterface $request |
|
12 | + */ |
|
13 | + private $request; |
|
14 | + |
|
15 | + |
|
16 | + /** |
|
17 | + * ThirdPartyPluginHandler constructor. |
|
18 | + * |
|
19 | + * @param RequestInterface $request |
|
20 | + */ |
|
21 | + public function __construct(RequestInterface $request) |
|
22 | + { |
|
23 | + $this->request = $request; |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + public function loadPlugins() |
|
28 | + { |
|
29 | + $this->wpApiBasicAuth(); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + private function wpApiBasicAuth() |
|
34 | + { |
|
35 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
36 | + // We want it for mobile apps. Just include the entire plugin |
|
37 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
38 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
39 | + // and causes a fatal error |
|
40 | + if ( |
|
41 | + ($this->request->isWordPressApi() || $this->request->isApi()) |
|
42 | + && ! $this->request->isActivation() |
|
43 | + && ! function_exists('json_basic_auth_handler') |
|
44 | + && ! function_exists('json_basic_auth_error') |
|
45 | + ) { |
|
46 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -3,25 +3,25 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php |
6 | - printf( |
|
7 | - esc_html__( |
|
8 | - 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | - 'event_espresso' |
|
10 | - ), |
|
11 | - '<em>', |
|
12 | - '</em>' |
|
13 | - ); |
|
14 | - ?> |
|
6 | + printf( |
|
7 | + esc_html__( |
|
8 | + 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | + 'event_espresso' |
|
10 | + ), |
|
11 | + '<em>', |
|
12 | + '</em>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php esc_html_e( |
18 | - 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <?php esc_html_e( |
24 | - 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | private function _get_datetimes_from_event(EE_Event $event) |
169 | 169 | { |
170 | 170 | return isset($this->_extra_data['data']->events) |
171 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + ? $this->_extra_data['data']->events[$event->ID()]['dtt_objs'] |
|
172 | 172 | : []; |
173 | 173 | } |
174 | 174 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
183 | 183 | { |
184 | 184 | return isset($this->_extra_data['data']->tickets) |
185 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
185 | + ? $this->_extra_data['data']->tickets[$ticket->ID()]['dtt_objs'] |
|
186 | 186 | : []; |
187 | 187 | } |
188 | 188 | } |
@@ -18,169 +18,169 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Datetime_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[DATETIME_LIST]' => esc_html__( |
|
27 | - 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | - 'event_espresso' |
|
29 | - ), |
|
30 | - ]; |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @param string $shortcode |
|
36 | - * @return string |
|
37 | - * @throws EE_Error |
|
38 | - * @throws ReflectionException |
|
39 | - */ |
|
40 | - protected function _parser($shortcode) |
|
41 | - { |
|
42 | - switch ($shortcode) { |
|
43 | - case '[DATETIME_LIST]': |
|
44 | - return $this->_get_datetime_list(); |
|
45 | - } |
|
46 | - return ''; |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
52 | - * |
|
53 | - * @return string |
|
54 | - * @throws EE_Error |
|
55 | - * @throws ReflectionException |
|
56 | - */ |
|
57 | - private function _get_datetime_list() |
|
58 | - { |
|
59 | - $this->_validate_list_requirements(); |
|
60 | - |
|
61 | - if ($this->_data['data'] instanceof EE_Ticket) { |
|
62 | - return $this->_get_datetime_list_for_ticket(); |
|
63 | - } |
|
64 | - if ($this->_data['data'] instanceof EE_Event) { |
|
65 | - return $this->_get_datetime_list_for_event(); |
|
66 | - } |
|
67 | - if ( |
|
68 | - $this->_data['data'] instanceof EE_Messages_Addressee |
|
69 | - && $this->_data['data']->reg_obj instanceof EE_Registration |
|
70 | - ) { |
|
71 | - return $this->_get_datetime_list_for_registration(); |
|
72 | - } |
|
73 | - // prevent recursive loop |
|
74 | - return ''; |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * return parsed list of datetimes for an event |
|
80 | - * |
|
81 | - * @return string |
|
82 | - * @throws EE_Error |
|
83 | - * @throws ReflectionException |
|
84 | - */ |
|
85 | - private function _get_datetime_list_for_event() |
|
86 | - { |
|
87 | - $event = $this->_data['data']; |
|
88 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
89 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
90 | - ? $this->_data['template']['datetime_list'] |
|
91 | - : $this->_extra_data['template']['datetime_list']; |
|
92 | - |
|
93 | - // here we're setting up the datetimes for the datetime list template for THIS event. |
|
94 | - $dtt_parsed = ''; |
|
95 | - $datetimes = $this->_get_datetimes_from_event($event); |
|
96 | - |
|
97 | - // each datetime in this case should be an datetime object. |
|
98 | - foreach ($datetimes as $datetime) { |
|
99 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
100 | - $template, |
|
101 | - $datetime, |
|
102 | - $valid_shortcodes, |
|
103 | - $this->_extra_data |
|
104 | - ); |
|
105 | - } |
|
106 | - |
|
107 | - return $dtt_parsed; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * return parsed list of datetimes for an ticket |
|
113 | - * |
|
114 | - * @return string |
|
115 | - * @throws EE_Error |
|
116 | - */ |
|
117 | - private function _get_datetime_list_for_ticket() |
|
118 | - { |
|
119 | - $valid_shortcodes = ['datetime', 'attendee']; |
|
120 | - |
|
121 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
122 | - ? $this->_data['template']['datetime_list'] |
|
123 | - : $this->_extra_data['template']['datetime_list']; |
|
124 | - $ticket = $this->_data['data']; |
|
125 | - |
|
126 | - // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
127 | - $dtt_parsed = ''; |
|
128 | - $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
129 | - |
|
130 | - // each datetime in this case should be an datetime object. |
|
131 | - foreach ($datetimes as $datetime) { |
|
132 | - $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
133 | - $template, |
|
134 | - $datetime, |
|
135 | - $valid_shortcodes, |
|
136 | - $this->_extra_data |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - return $dtt_parsed; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * return parsed list of datetimes from a given registration. |
|
146 | - * |
|
147 | - * @return string |
|
148 | - * @throws EE_Error |
|
149 | - * @throws EE_Error |
|
150 | - */ |
|
151 | - private function _get_datetime_list_for_registration() |
|
152 | - { |
|
153 | - $registration = $this->_data['data']->reg_obj; |
|
154 | - |
|
155 | - // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
156 | - $this->_data['data'] = $registration->ticket(); |
|
157 | - return $this->_get_datetime_list_for_ticket(); |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param EE_Event $event |
|
163 | - * @return array|mixed |
|
164 | - * @throws EE_Error |
|
165 | - * @throws ReflectionException |
|
166 | - */ |
|
167 | - private function _get_datetimes_from_event(EE_Event $event) |
|
168 | - { |
|
169 | - return isset($this->_extra_data['data']->events) |
|
170 | - ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | - : []; |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * @param EE_Ticket $ticket |
|
177 | - * @return array|mixed |
|
178 | - * @throws EE_Error |
|
179 | - */ |
|
180 | - private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
181 | - { |
|
182 | - return isset($this->_extra_data['data']->tickets) |
|
183 | - ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
184 | - : []; |
|
185 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Datetime List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to datetime lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[DATETIME_LIST]' => esc_html__( |
|
27 | + 'Will output a list of datetimes according to the layout specified in the datetime list field.', |
|
28 | + 'event_espresso' |
|
29 | + ), |
|
30 | + ]; |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @param string $shortcode |
|
36 | + * @return string |
|
37 | + * @throws EE_Error |
|
38 | + * @throws ReflectionException |
|
39 | + */ |
|
40 | + protected function _parser($shortcode) |
|
41 | + { |
|
42 | + switch ($shortcode) { |
|
43 | + case '[DATETIME_LIST]': |
|
44 | + return $this->_get_datetime_list(); |
|
45 | + } |
|
46 | + return ''; |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
52 | + * |
|
53 | + * @return string |
|
54 | + * @throws EE_Error |
|
55 | + * @throws ReflectionException |
|
56 | + */ |
|
57 | + private function _get_datetime_list() |
|
58 | + { |
|
59 | + $this->_validate_list_requirements(); |
|
60 | + |
|
61 | + if ($this->_data['data'] instanceof EE_Ticket) { |
|
62 | + return $this->_get_datetime_list_for_ticket(); |
|
63 | + } |
|
64 | + if ($this->_data['data'] instanceof EE_Event) { |
|
65 | + return $this->_get_datetime_list_for_event(); |
|
66 | + } |
|
67 | + if ( |
|
68 | + $this->_data['data'] instanceof EE_Messages_Addressee |
|
69 | + && $this->_data['data']->reg_obj instanceof EE_Registration |
|
70 | + ) { |
|
71 | + return $this->_get_datetime_list_for_registration(); |
|
72 | + } |
|
73 | + // prevent recursive loop |
|
74 | + return ''; |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * return parsed list of datetimes for an event |
|
80 | + * |
|
81 | + * @return string |
|
82 | + * @throws EE_Error |
|
83 | + * @throws ReflectionException |
|
84 | + */ |
|
85 | + private function _get_datetime_list_for_event() |
|
86 | + { |
|
87 | + $event = $this->_data['data']; |
|
88 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
89 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
90 | + ? $this->_data['template']['datetime_list'] |
|
91 | + : $this->_extra_data['template']['datetime_list']; |
|
92 | + |
|
93 | + // here we're setting up the datetimes for the datetime list template for THIS event. |
|
94 | + $dtt_parsed = ''; |
|
95 | + $datetimes = $this->_get_datetimes_from_event($event); |
|
96 | + |
|
97 | + // each datetime in this case should be an datetime object. |
|
98 | + foreach ($datetimes as $datetime) { |
|
99 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
100 | + $template, |
|
101 | + $datetime, |
|
102 | + $valid_shortcodes, |
|
103 | + $this->_extra_data |
|
104 | + ); |
|
105 | + } |
|
106 | + |
|
107 | + return $dtt_parsed; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * return parsed list of datetimes for an ticket |
|
113 | + * |
|
114 | + * @return string |
|
115 | + * @throws EE_Error |
|
116 | + */ |
|
117 | + private function _get_datetime_list_for_ticket() |
|
118 | + { |
|
119 | + $valid_shortcodes = ['datetime', 'attendee']; |
|
120 | + |
|
121 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['datetime_list']) |
|
122 | + ? $this->_data['template']['datetime_list'] |
|
123 | + : $this->_extra_data['template']['datetime_list']; |
|
124 | + $ticket = $this->_data['data']; |
|
125 | + |
|
126 | + // here we're setting up the datetimes for the datetime list template for THIS ticket. |
|
127 | + $dtt_parsed = ''; |
|
128 | + $datetimes = $this->_get_datetimes_from_ticket($ticket); |
|
129 | + |
|
130 | + // each datetime in this case should be an datetime object. |
|
131 | + foreach ($datetimes as $datetime) { |
|
132 | + $dtt_parsed .= $this->_shortcode_helper->parse_datetime_list_template( |
|
133 | + $template, |
|
134 | + $datetime, |
|
135 | + $valid_shortcodes, |
|
136 | + $this->_extra_data |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + return $dtt_parsed; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * return parsed list of datetimes from a given registration. |
|
146 | + * |
|
147 | + * @return string |
|
148 | + * @throws EE_Error |
|
149 | + * @throws EE_Error |
|
150 | + */ |
|
151 | + private function _get_datetime_list_for_registration() |
|
152 | + { |
|
153 | + $registration = $this->_data['data']->reg_obj; |
|
154 | + |
|
155 | + // now let's just get the ticket, set $this->_data['data'] to the ticket and then call _get_datetime_list_for__ticket(); |
|
156 | + $this->_data['data'] = $registration->ticket(); |
|
157 | + return $this->_get_datetime_list_for_ticket(); |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param EE_Event $event |
|
163 | + * @return array|mixed |
|
164 | + * @throws EE_Error |
|
165 | + * @throws ReflectionException |
|
166 | + */ |
|
167 | + private function _get_datetimes_from_event(EE_Event $event) |
|
168 | + { |
|
169 | + return isset($this->_extra_data['data']->events) |
|
170 | + ? $this->_extra_data['data']->events[ $event->ID() ]['dtt_objs'] |
|
171 | + : []; |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * @param EE_Ticket $ticket |
|
177 | + * @return array|mixed |
|
178 | + * @throws EE_Error |
|
179 | + */ |
|
180 | + private function _get_datetimes_from_ticket(EE_Ticket $ticket) |
|
181 | + { |
|
182 | + return isset($this->_extra_data['data']->tickets) |
|
183 | + ? $this->_extra_data['data']->tickets[ $ticket->ID() ]['dtt_objs'] |
|
184 | + : []; |
|
185 | + } |
|
186 | 186 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | private function _get_tickets_from_event(EE_Event $event) |
203 | 203 | { |
204 | 204 | return isset($this->_extra_data['data']->events) |
205 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | + ? $this->_extra_data['data']->events[$event->ID()]['tkt_objs'] |
|
206 | 206 | : []; |
207 | 207 | } |
208 | 208 | |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | private function _get_ticket_list_from_registration(EE_Registration $registration) |
217 | 217 | { |
218 | 218 | return isset($this->_extra_data['data']->registrations) |
219 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['tkt_obj']] |
|
220 | 220 | : []; |
221 | 221 | } |
222 | 222 | } |
@@ -18,204 +18,204 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Ticket_List_Shortcodes extends EE_Shortcodes |
20 | 20 | { |
21 | - protected function _init_props() |
|
22 | - { |
|
23 | - $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
24 | - $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
25 | - $this->_shortcodes = [ |
|
26 | - '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
27 | - ]; |
|
28 | - } |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * @param string $shortcode |
|
33 | - * @return string |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - protected function _parser($shortcode) |
|
38 | - { |
|
39 | - switch ($shortcode) { |
|
40 | - case '[TICKET_LIST]': |
|
41 | - return $this->_get_ticket_list(); |
|
42 | - } |
|
43 | - return ''; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
49 | - * |
|
50 | - * @return string |
|
51 | - * @throws EE_Error |
|
52 | - * @throws ReflectionException |
|
53 | - */ |
|
54 | - private function _get_ticket_list() |
|
55 | - { |
|
56 | - $this->_validate_list_requirements(); |
|
57 | - |
|
58 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
59 | - return $this->_get_ticket_list_for_main(); |
|
60 | - } |
|
61 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
62 | - return $this->_get_ticket_list_for_attendee(); |
|
63 | - } |
|
64 | - if ($this->_data['data'] instanceof EE_Event) { |
|
65 | - return $this->_get_ticket_list_for_event(); |
|
66 | - } |
|
67 | - // prevent recursive loop |
|
68 | - return ''; |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * This returns the parsed ticket list for main template; |
|
74 | - */ |
|
75 | - private function _get_ticket_list_for_main() |
|
76 | - { |
|
77 | - $valid_shortcodes = [ |
|
78 | - 'ticket', |
|
79 | - 'event_list', |
|
80 | - 'attendee_list', |
|
81 | - 'datetime_list', |
|
82 | - 'attendee', |
|
83 | - 'line_item_list', |
|
84 | - 'primary_registration_details', |
|
85 | - 'recipient_details', |
|
86 | - ]; |
|
87 | - $template = $this->_data['template']; |
|
88 | - $data = $this->_data['data']; |
|
89 | - $ticket_list = ''; |
|
90 | - |
|
91 | - |
|
92 | - // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
93 | - foreach ($data->tickets as $ticket) { |
|
94 | - $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
95 | - $template, |
|
96 | - $ticket['ticket'], |
|
97 | - $valid_shortcodes, |
|
98 | - $this->_extra_data |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - return $ticket_list; |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * return parsed list of tickets for an event |
|
108 | - * |
|
109 | - * @return string |
|
110 | - * @throws EE_Error |
|
111 | - * @throws ReflectionException |
|
112 | - */ |
|
113 | - private function _get_ticket_list_for_event() |
|
114 | - { |
|
115 | - $valid_shortcodes = [ |
|
116 | - 'ticket', |
|
117 | - 'attendee_list', |
|
118 | - 'datetime_list', |
|
119 | - 'attendee', |
|
120 | - 'venue', |
|
121 | - 'line_item_list', |
|
122 | - 'primary_registration_details', |
|
123 | - 'recipient_details', |
|
124 | - ]; |
|
125 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
126 | - ? $this->_data['template']['ticket_list'] |
|
127 | - : $this->_extra_data['template']['ticket_list']; |
|
128 | - $event = $this->_data['data']; |
|
129 | - |
|
130 | - // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
131 | - $template = str_replace('[EVENT_LIST]', '', $template); |
|
132 | - |
|
133 | - // here we're setting up the tickets for the ticket list template for THIS event. |
|
134 | - $tkt_parsed = ''; |
|
135 | - $tickets = $this->_get_tickets_from_event($event); |
|
136 | - |
|
137 | - // each ticket in this case should be an ticket object. |
|
138 | - foreach ($tickets 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 | - |
|
147 | - return $tkt_parsed; |
|
148 | - } |
|
149 | - |
|
150 | - |
|
151 | - /** |
|
152 | - * return parsed list of tickets for an attendee |
|
153 | - * |
|
154 | - * @return string |
|
155 | - * @throws EE_Error |
|
156 | - * @throws ReflectionException |
|
157 | - */ |
|
158 | - private function _get_ticket_list_for_attendee() |
|
159 | - { |
|
160 | - $valid_shortcodes = [ |
|
161 | - 'ticket', |
|
162 | - 'event_list', |
|
163 | - 'datetime_list', |
|
164 | - 'attendee', |
|
165 | - 'primary_registration_details', |
|
166 | - 'recipient_details', |
|
167 | - ]; |
|
168 | - |
|
169 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
170 | - ? $this->_data['template']['ticket_list'] |
|
171 | - : $this->_extra_data['template']['ticket_list']; |
|
172 | - $registration = $this->_data['data']; |
|
173 | - |
|
174 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
175 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
176 | - |
|
177 | - // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
178 | - $tkt_parsed = ''; |
|
179 | - $tickets = $this->_get_ticket_list_from_registration($registration); |
|
180 | - |
|
181 | - // each ticket in this case should be an ticket object. |
|
182 | - foreach ($tickets as $ticket) { |
|
183 | - $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
184 | - $template, |
|
185 | - $ticket, |
|
186 | - $valid_shortcodes, |
|
187 | - $this->_extra_data |
|
188 | - ); |
|
189 | - } |
|
190 | - |
|
191 | - return $tkt_parsed; |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * @param EE_Event $event |
|
197 | - * @return array|mixed |
|
198 | - * @throws EE_Error |
|
199 | - * @throws ReflectionException |
|
200 | - */ |
|
201 | - private function _get_tickets_from_event(EE_Event $event) |
|
202 | - { |
|
203 | - return isset($this->_extra_data['data']->events) |
|
204 | - ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | - : []; |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - /** |
|
210 | - * @param EE_Registration $registration |
|
211 | - * @return array |
|
212 | - * @throws EE_Error |
|
213 | - * @throws ReflectionException |
|
214 | - */ |
|
215 | - private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
216 | - { |
|
217 | - return isset($this->_extra_data['data']->registrations) |
|
218 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | - : []; |
|
220 | - } |
|
21 | + protected function _init_props() |
|
22 | + { |
|
23 | + $this->label = esc_html__('Ticket List Shortcodes', 'event_espresso'); |
|
24 | + $this->description = esc_html__('All shortcodes specific to ticket lists', 'event_espresso'); |
|
25 | + $this->_shortcodes = [ |
|
26 | + '[TICKET_LIST]' => esc_html__('Will output a list of tickets', 'event_espresso'), |
|
27 | + ]; |
|
28 | + } |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * @param string $shortcode |
|
33 | + * @return string |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + protected function _parser($shortcode) |
|
38 | + { |
|
39 | + switch ($shortcode) { |
|
40 | + case '[TICKET_LIST]': |
|
41 | + return $this->_get_ticket_list(); |
|
42 | + } |
|
43 | + return ''; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
49 | + * |
|
50 | + * @return string |
|
51 | + * @throws EE_Error |
|
52 | + * @throws ReflectionException |
|
53 | + */ |
|
54 | + private function _get_ticket_list() |
|
55 | + { |
|
56 | + $this->_validate_list_requirements(); |
|
57 | + |
|
58 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
59 | + return $this->_get_ticket_list_for_main(); |
|
60 | + } |
|
61 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
62 | + return $this->_get_ticket_list_for_attendee(); |
|
63 | + } |
|
64 | + if ($this->_data['data'] instanceof EE_Event) { |
|
65 | + return $this->_get_ticket_list_for_event(); |
|
66 | + } |
|
67 | + // prevent recursive loop |
|
68 | + return ''; |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * This returns the parsed ticket list for main template; |
|
74 | + */ |
|
75 | + private function _get_ticket_list_for_main() |
|
76 | + { |
|
77 | + $valid_shortcodes = [ |
|
78 | + 'ticket', |
|
79 | + 'event_list', |
|
80 | + 'attendee_list', |
|
81 | + 'datetime_list', |
|
82 | + 'attendee', |
|
83 | + 'line_item_list', |
|
84 | + 'primary_registration_details', |
|
85 | + 'recipient_details', |
|
86 | + ]; |
|
87 | + $template = $this->_data['template']; |
|
88 | + $data = $this->_data['data']; |
|
89 | + $ticket_list = ''; |
|
90 | + |
|
91 | + |
|
92 | + // now we need to loop through the ticket list and send data to the EE_Parser helper. |
|
93 | + foreach ($data->tickets as $ticket) { |
|
94 | + $ticket_list .= $this->_shortcode_helper->parse_ticket_list_template( |
|
95 | + $template, |
|
96 | + $ticket['ticket'], |
|
97 | + $valid_shortcodes, |
|
98 | + $this->_extra_data |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + return $ticket_list; |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * return parsed list of tickets for an event |
|
108 | + * |
|
109 | + * @return string |
|
110 | + * @throws EE_Error |
|
111 | + * @throws ReflectionException |
|
112 | + */ |
|
113 | + private function _get_ticket_list_for_event() |
|
114 | + { |
|
115 | + $valid_shortcodes = [ |
|
116 | + 'ticket', |
|
117 | + 'attendee_list', |
|
118 | + 'datetime_list', |
|
119 | + 'attendee', |
|
120 | + 'venue', |
|
121 | + 'line_item_list', |
|
122 | + 'primary_registration_details', |
|
123 | + 'recipient_details', |
|
124 | + ]; |
|
125 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
126 | + ? $this->_data['template']['ticket_list'] |
|
127 | + : $this->_extra_data['template']['ticket_list']; |
|
128 | + $event = $this->_data['data']; |
|
129 | + |
|
130 | + // let's remove any existing [EVENT_LIST] shortcodes from the ticket list template so that we don't get recursion. |
|
131 | + $template = str_replace('[EVENT_LIST]', '', $template); |
|
132 | + |
|
133 | + // here we're setting up the tickets for the ticket list template for THIS event. |
|
134 | + $tkt_parsed = ''; |
|
135 | + $tickets = $this->_get_tickets_from_event($event); |
|
136 | + |
|
137 | + // each ticket in this case should be an ticket object. |
|
138 | + foreach ($tickets 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 | + |
|
147 | + return $tkt_parsed; |
|
148 | + } |
|
149 | + |
|
150 | + |
|
151 | + /** |
|
152 | + * return parsed list of tickets for an attendee |
|
153 | + * |
|
154 | + * @return string |
|
155 | + * @throws EE_Error |
|
156 | + * @throws ReflectionException |
|
157 | + */ |
|
158 | + private function _get_ticket_list_for_attendee() |
|
159 | + { |
|
160 | + $valid_shortcodes = [ |
|
161 | + 'ticket', |
|
162 | + 'event_list', |
|
163 | + 'datetime_list', |
|
164 | + 'attendee', |
|
165 | + 'primary_registration_details', |
|
166 | + 'recipient_details', |
|
167 | + ]; |
|
168 | + |
|
169 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['ticket_list']) |
|
170 | + ? $this->_data['template']['ticket_list'] |
|
171 | + : $this->_extra_data['template']['ticket_list']; |
|
172 | + $registration = $this->_data['data']; |
|
173 | + |
|
174 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the ticket list template so that we don't get recursion. |
|
175 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
176 | + |
|
177 | + // here we're setting up the tickets for the ticket list template for THIS attendee. |
|
178 | + $tkt_parsed = ''; |
|
179 | + $tickets = $this->_get_ticket_list_from_registration($registration); |
|
180 | + |
|
181 | + // each ticket in this case should be an ticket object. |
|
182 | + foreach ($tickets as $ticket) { |
|
183 | + $tkt_parsed .= $this->_shortcode_helper->parse_ticket_list_template( |
|
184 | + $template, |
|
185 | + $ticket, |
|
186 | + $valid_shortcodes, |
|
187 | + $this->_extra_data |
|
188 | + ); |
|
189 | + } |
|
190 | + |
|
191 | + return $tkt_parsed; |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * @param EE_Event $event |
|
197 | + * @return array|mixed |
|
198 | + * @throws EE_Error |
|
199 | + * @throws ReflectionException |
|
200 | + */ |
|
201 | + private function _get_tickets_from_event(EE_Event $event) |
|
202 | + { |
|
203 | + return isset($this->_extra_data['data']->events) |
|
204 | + ? $this->_extra_data['data']->events[ $event->ID() ]['tkt_objs'] |
|
205 | + : []; |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + /** |
|
210 | + * @param EE_Registration $registration |
|
211 | + * @return array |
|
212 | + * @throws EE_Error |
|
213 | + * @throws ReflectionException |
|
214 | + */ |
|
215 | + private function _get_ticket_list_from_registration(EE_Registration $registration) |
|
216 | + { |
|
217 | + return isset($this->_extra_data['data']->registrations) |
|
218 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['tkt_obj']] |
|
219 | + : []; |
|
220 | + } |
|
221 | 221 | } |
@@ -163,7 +163,7 @@ |
||
163 | 163 | private function _get_events_from_registration(EE_Registration $registration) |
164 | 164 | { |
165 | 165 | return isset($this->_extra_data['data']->registrations) |
166 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
166 | + ? [$this->_extra_data['data']->registrations[$registration->ID()]['evt_obj']] |
|
167 | 167 | : []; |
168 | 168 | } |
169 | 169 | } |
@@ -18,156 +18,156 @@ |
||
18 | 18 | */ |
19 | 19 | class EE_Event_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__('Event List Shortcodes', 'event_espresso'); |
|
30 | - $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | - $this->_shortcodes = [ |
|
32 | - '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | - ]; |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $shortcode |
|
39 | - * @return string |
|
40 | - * @throws EE_Error |
|
41 | - * @throws ReflectionException |
|
42 | - */ |
|
43 | - protected function _parser($shortcode) |
|
44 | - { |
|
45 | - switch ($shortcode) { |
|
46 | - case '[EVENT_LIST]': |
|
47 | - return $this->_get_event_list(); |
|
48 | - } |
|
49 | - return ''; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | - * |
|
56 | - * @return string |
|
57 | - * @throws EE_Error |
|
58 | - * @throws ReflectionException |
|
59 | - */ |
|
60 | - private function _get_event_list() |
|
61 | - { |
|
62 | - $this->_validate_list_requirements(); |
|
63 | - |
|
64 | - if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | - return $this->_get_event_list_for_main(); |
|
66 | - } |
|
67 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | - return $this->_get_event_list_for_registration(); |
|
69 | - } |
|
70 | - // prevent recursive loop |
|
71 | - return ''; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * This returns the parsed event list for main template |
|
77 | - * |
|
78 | - * @return string |
|
79 | - */ |
|
80 | - private function _get_event_list_for_main() |
|
81 | - { |
|
82 | - |
|
83 | - $valid_shortcodes = [ |
|
84 | - 'event', |
|
85 | - 'attendee_list', |
|
86 | - 'ticket_list', |
|
87 | - 'datetime_list', |
|
88 | - 'venue', |
|
89 | - 'attendee', |
|
90 | - 'recipient_list', |
|
91 | - 'recipient_details', |
|
92 | - 'primary_registration_list', |
|
93 | - 'primary_registration_details', |
|
94 | - 'event_author', |
|
95 | - 'organization', |
|
96 | - ]; |
|
97 | - $template = $this->_data['template']; |
|
98 | - $data = $this->_data['data']; |
|
99 | - $events = ''; |
|
100 | - |
|
101 | - // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
102 | - foreach ($data->events as $event) { |
|
103 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
104 | - $template, |
|
105 | - $event['event'], |
|
106 | - $valid_shortcodes, |
|
107 | - $this->_extra_data |
|
108 | - ); |
|
109 | - } |
|
110 | - return $events; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * This returns the parsed event list for an attendee |
|
116 | - * |
|
117 | - * @return string |
|
118 | - * @throws EE_Error |
|
119 | - * @throws ReflectionException |
|
120 | - */ |
|
121 | - private function _get_event_list_for_registration() |
|
122 | - { |
|
123 | - $valid_shortcodes = [ |
|
124 | - 'event', |
|
125 | - 'ticket_list', |
|
126 | - 'datetime_list', |
|
127 | - 'attendee', |
|
128 | - 'event_author', |
|
129 | - 'recipient_details', |
|
130 | - 'recipient_list', |
|
131 | - 'venue', |
|
132 | - 'organization', |
|
133 | - ]; |
|
134 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
135 | - ? $this->_data['template']['event_list'] |
|
136 | - : $this->_extra_data['template']['event_list']; |
|
137 | - $registration = $this->_data['data']; |
|
138 | - |
|
139 | - // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
140 | - $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
141 | - |
|
142 | - // here we're setting up the events for the event_list template for THIS registration. |
|
143 | - $all_events = $this->_get_events_from_registration($registration); |
|
144 | - |
|
145 | - // we're NOT going to prepare a list of attendees this time around |
|
146 | - $events = ''; |
|
147 | - |
|
148 | - foreach ($all_events as $event) { |
|
149 | - $events .= $this->_shortcode_helper->parse_event_list_template( |
|
150 | - $template, |
|
151 | - $event, |
|
152 | - $valid_shortcodes, |
|
153 | - $this->_extra_data |
|
154 | - ); |
|
155 | - } |
|
156 | - |
|
157 | - return $events; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param EE_Registration $registration |
|
163 | - * @return array |
|
164 | - * @throws EE_Error |
|
165 | - * @throws ReflectionException |
|
166 | - */ |
|
167 | - private function _get_events_from_registration(EE_Registration $registration) |
|
168 | - { |
|
169 | - return isset($this->_extra_data['data']->registrations) |
|
170 | - ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
171 | - : []; |
|
172 | - } |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct(); |
|
24 | + } |
|
25 | + |
|
26 | + |
|
27 | + protected function _init_props() |
|
28 | + { |
|
29 | + $this->label = esc_html__('Event List Shortcodes', 'event_espresso'); |
|
30 | + $this->description = esc_html__('All shortcodes specific to event lists', 'event_espresso'); |
|
31 | + $this->_shortcodes = [ |
|
32 | + '[EVENT_LIST]' => esc_html__('Will output a list of events', 'event_espresso'), |
|
33 | + ]; |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $shortcode |
|
39 | + * @return string |
|
40 | + * @throws EE_Error |
|
41 | + * @throws ReflectionException |
|
42 | + */ |
|
43 | + protected function _parser($shortcode) |
|
44 | + { |
|
45 | + switch ($shortcode) { |
|
46 | + case '[EVENT_LIST]': |
|
47 | + return $this->_get_event_list(); |
|
48 | + } |
|
49 | + return ''; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * figure out what the incoming data is and then return the appropriate parsed value. |
|
55 | + * |
|
56 | + * @return string |
|
57 | + * @throws EE_Error |
|
58 | + * @throws ReflectionException |
|
59 | + */ |
|
60 | + private function _get_event_list() |
|
61 | + { |
|
62 | + $this->_validate_list_requirements(); |
|
63 | + |
|
64 | + if ($this->_data['data'] instanceof EE_Messages_Addressee) { |
|
65 | + return $this->_get_event_list_for_main(); |
|
66 | + } |
|
67 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
68 | + return $this->_get_event_list_for_registration(); |
|
69 | + } |
|
70 | + // prevent recursive loop |
|
71 | + return ''; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * This returns the parsed event list for main template |
|
77 | + * |
|
78 | + * @return string |
|
79 | + */ |
|
80 | + private function _get_event_list_for_main() |
|
81 | + { |
|
82 | + |
|
83 | + $valid_shortcodes = [ |
|
84 | + 'event', |
|
85 | + 'attendee_list', |
|
86 | + 'ticket_list', |
|
87 | + 'datetime_list', |
|
88 | + 'venue', |
|
89 | + 'attendee', |
|
90 | + 'recipient_list', |
|
91 | + 'recipient_details', |
|
92 | + 'primary_registration_list', |
|
93 | + 'primary_registration_details', |
|
94 | + 'event_author', |
|
95 | + 'organization', |
|
96 | + ]; |
|
97 | + $template = $this->_data['template']; |
|
98 | + $data = $this->_data['data']; |
|
99 | + $events = ''; |
|
100 | + |
|
101 | + // now we need to loop through the events array in EE_Messages_Addressee and send data to the EE_Parser helper. |
|
102 | + foreach ($data->events as $event) { |
|
103 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
104 | + $template, |
|
105 | + $event['event'], |
|
106 | + $valid_shortcodes, |
|
107 | + $this->_extra_data |
|
108 | + ); |
|
109 | + } |
|
110 | + return $events; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * This returns the parsed event list for an attendee |
|
116 | + * |
|
117 | + * @return string |
|
118 | + * @throws EE_Error |
|
119 | + * @throws ReflectionException |
|
120 | + */ |
|
121 | + private function _get_event_list_for_registration() |
|
122 | + { |
|
123 | + $valid_shortcodes = [ |
|
124 | + 'event', |
|
125 | + 'ticket_list', |
|
126 | + 'datetime_list', |
|
127 | + 'attendee', |
|
128 | + 'event_author', |
|
129 | + 'recipient_details', |
|
130 | + 'recipient_list', |
|
131 | + 'venue', |
|
132 | + 'organization', |
|
133 | + ]; |
|
134 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['event_list']) |
|
135 | + ? $this->_data['template']['event_list'] |
|
136 | + : $this->_extra_data['template']['event_list']; |
|
137 | + $registration = $this->_data['data']; |
|
138 | + |
|
139 | + // let's remove any existing [ATTENDEE_LIST] shortcode from the event list template so that we don't get recursion. |
|
140 | + $template = str_replace('[ATTENDEE_LIST]', '', $template); |
|
141 | + |
|
142 | + // here we're setting up the events for the event_list template for THIS registration. |
|
143 | + $all_events = $this->_get_events_from_registration($registration); |
|
144 | + |
|
145 | + // we're NOT going to prepare a list of attendees this time around |
|
146 | + $events = ''; |
|
147 | + |
|
148 | + foreach ($all_events as $event) { |
|
149 | + $events .= $this->_shortcode_helper->parse_event_list_template( |
|
150 | + $template, |
|
151 | + $event, |
|
152 | + $valid_shortcodes, |
|
153 | + $this->_extra_data |
|
154 | + ); |
|
155 | + } |
|
156 | + |
|
157 | + return $events; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param EE_Registration $registration |
|
163 | + * @return array |
|
164 | + * @throws EE_Error |
|
165 | + * @throws ReflectionException |
|
166 | + */ |
|
167 | + private function _get_events_from_registration(EE_Registration $registration) |
|
168 | + { |
|
169 | + return isset($this->_extra_data['data']->registrations) |
|
170 | + ? [$this->_extra_data['data']->registrations[ $registration->ID() ]['evt_obj']] |
|
171 | + : []; |
|
172 | + } |
|
173 | 173 | } |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <div class="padding"> |
2 | 2 | <p> |
3 | 3 | <?php |
4 | - printf( |
|
5 | - esc_html__( |
|
6 | - 'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!', |
|
7 | - 'event_espresso' |
|
8 | - ), |
|
9 | - '<a |
|
4 | + printf( |
|
5 | + esc_html__( |
|
6 | + 'Upgrade to an %1$sEvent Espresso 4 support license%2$s to get access to dedicated support staff and premium features, such as a calendar, printable tickets and check-in capabilities, MailChimp integration, and more!', |
|
7 | + 'event_espresso' |
|
8 | + ), |
|
9 | + '<a |
|
10 | 10 | href="https://eventespresso.com/pricing/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link" |
11 | 11 | target="_blank">', |
12 | - '</a>' |
|
13 | - ); |
|
14 | - ?> |
|
12 | + '</a>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner' |
@@ -23,16 +23,16 @@ discard block |
||
23 | 23 | </p> |
24 | 24 | <p> |
25 | 25 | <?php |
26 | - printf( |
|
27 | - esc_html__( |
|
28 | - 'Visit %1$sEvent Espresso%2$s for more details.', |
|
29 | - 'event_espresso' |
|
30 | - ), |
|
31 | - '<a |
|
26 | + printf( |
|
27 | + esc_html__( |
|
28 | + 'Visit %1$sEvent Espresso%2$s for more details.', |
|
29 | + 'event_espresso' |
|
30 | + ), |
|
31 | + '<a |
|
32 | 32 | href="https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=link" |
33 | 33 | target="_blank">', |
34 | - '</a>' |
|
35 | - ); |
|
36 | - ?> |
|
34 | + '</a>' |
|
35 | + ); |
|
36 | + ?> |
|
37 | 37 | </p> |
38 | 38 | </div> |
@@ -17,7 +17,7 @@ |
||
17 | 17 | <a href='https://eventespresso.com/?ee_ver=ee4&utm_source=ee4_plugin_admin&utm_medium=link&utm_campaign=event_espresso_highlights_widget&utm_content=banner' |
18 | 18 | target='_blank'> |
19 | 19 | <img alt="<?php esc_html_e('manage events faster', 'event_espresso'); ?>" |
20 | - src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL . 'images/manage-events-faster-240x240.jpg'); ?>" |
|
20 | + src="<?php echo esc_url_raw(EE_GLOBAL_ASSETS_URL.'images/manage-events-faster-240x240.jpg'); ?>" |
|
21 | 21 | /> |
22 | 22 | </a> |
23 | 23 | </p> |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | 'table_alias' => $field_obj->get_table_alias(), |
84 | 84 | 'table_column' => $field_obj->get_table_column(), |
85 | 85 | ); |
86 | - $fields_json[ $field_json['name'] ] = $field_json; |
|
86 | + $fields_json[$field_json['name']] = $field_json; |
|
87 | 87 | } |
88 | 88 | $fields_json = array_merge( |
89 | 89 | $fields_json, |
90 | 90 | $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
91 | 91 | ); |
92 | - $response[ $model_name ]['fields'] = apply_filters( |
|
92 | + $response[$model_name]['fields'] = apply_filters( |
|
93 | 93 | 'FHEE__Meta__handle_request_models_meta__fields', |
94 | 94 | $fields_json, |
95 | 95 | $model |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | 'type' => str_replace('EE_', '', get_class($relation_obj)), |
102 | 102 | 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
103 | 103 | ); |
104 | - $relations_json[ $relation_name ] = $relation_json; |
|
104 | + $relations_json[$relation_name] = $relation_json; |
|
105 | 105 | } |
106 | - $response[ $model_name ]['relations'] = apply_filters( |
|
106 | + $response[$model_name]['relations'] = apply_filters( |
|
107 | 107 | 'FHEE__Meta__handle_request_models_meta__relations', |
108 | 108 | $relations_json, |
109 | 109 | $model |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | 'name' => $addon->name(), |
129 | 129 | 'version' => $addon->version(), |
130 | 130 | ); |
131 | - $addons[ $addon_json['name'] ] = $addon_json; |
|
131 | + $addons[$addon_json['name']] = $addon_json; |
|
132 | 132 | } |
133 | 133 | $response_data['ee'] = array( |
134 | 134 | 'version' => EEM_System_Status::instance()->get_ee_version(), |
@@ -24,122 +24,122 @@ |
||
24 | 24 | */ |
25 | 25 | class Meta extends Base |
26 | 26 | { |
27 | - /** |
|
28 | - * @param WP_REST_Request $request |
|
29 | - * @param string $version |
|
30 | - * @return array|WP_REST_Response |
|
31 | - */ |
|
32 | - public static function handleRequestModelsMeta($request, $version) |
|
33 | - { |
|
34 | - $controller = new Meta(); |
|
35 | - try { |
|
36 | - $controller->setRequestedVersion($version); |
|
37 | - return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
38 | - } catch (Exception $e) { |
|
39 | - return $controller->sendResponse($e); |
|
40 | - } |
|
41 | - } |
|
27 | + /** |
|
28 | + * @param WP_REST_Request $request |
|
29 | + * @param string $version |
|
30 | + * @return array|WP_REST_Response |
|
31 | + */ |
|
32 | + public static function handleRequestModelsMeta($request, $version) |
|
33 | + { |
|
34 | + $controller = new Meta(); |
|
35 | + try { |
|
36 | + $controller->setRequestedVersion($version); |
|
37 | + return $controller->sendResponse($controller->getModelsMetadataEntity()); |
|
38 | + } catch (Exception $e) { |
|
39 | + return $controller->sendResponse($e); |
|
40 | + } |
|
41 | + } |
|
42 | 42 | |
43 | 43 | |
44 | - /* |
|
44 | + /* |
|
45 | 45 | * Gets the model metadata resource entity |
46 | 46 | * @return array for JSON response, describing all the models available in teh requested version |
47 | 47 | */ |
48 | - protected function getModelsMetadataEntity() |
|
49 | - { |
|
50 | - $response = array(); |
|
51 | - foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
52 | - $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
53 | - $fields_json = array(); |
|
54 | - foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
55 | - if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
56 | - continue; |
|
57 | - } |
|
58 | - if ($field_obj instanceof EE_Boolean_Field) { |
|
59 | - $datatype = 'Boolean'; |
|
60 | - } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
61 | - $datatype = 'Number'; |
|
62 | - } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
63 | - $datatype = 'Object'; |
|
64 | - } else { |
|
65 | - $datatype = 'String'; |
|
66 | - } |
|
67 | - $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
68 | - $field_obj, |
|
69 | - $field_obj->get_default_value(), |
|
70 | - $this->getModelVersionInfo()->requestedVersion() |
|
71 | - ); |
|
72 | - $field_json = array( |
|
73 | - 'name' => $field_name, |
|
74 | - 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
75 | - 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
76 | - 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
77 | - 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
78 | - 'datatype' => $datatype, |
|
79 | - 'nullable' => $field_obj->is_nullable(), |
|
80 | - 'default' => $default_value, |
|
81 | - 'table_alias' => $field_obj->get_table_alias(), |
|
82 | - 'table_column' => $field_obj->get_table_column(), |
|
83 | - ); |
|
84 | - $fields_json[ $field_json['name'] ] = $field_json; |
|
85 | - } |
|
86 | - $fields_json = array_merge( |
|
87 | - $fields_json, |
|
88 | - $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
89 | - ); |
|
90 | - $response[ $model_name ]['fields'] = apply_filters( |
|
91 | - 'FHEE__Meta__handle_request_models_meta__fields', |
|
92 | - $fields_json, |
|
93 | - $model |
|
94 | - ); |
|
95 | - $relations_json = array(); |
|
96 | - foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
97 | - $relation_json = array( |
|
98 | - 'name' => $relation_name, |
|
99 | - 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
100 | - 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
|
101 | - ); |
|
102 | - $relations_json[ $relation_name ] = $relation_json; |
|
103 | - } |
|
104 | - $response[ $model_name ]['relations'] = apply_filters( |
|
105 | - 'FHEE__Meta__handle_request_models_meta__relations', |
|
106 | - $relations_json, |
|
107 | - $model |
|
108 | - ); |
|
109 | - } |
|
110 | - return $response; |
|
111 | - } |
|
48 | + protected function getModelsMetadataEntity() |
|
49 | + { |
|
50 | + $response = array(); |
|
51 | + foreach ($this->getModelVersionInfo()->modelsForRequestedVersion() as $model_name => $model_classname) { |
|
52 | + $model = $this->getModelVersionInfo()->loadModel($model_name); |
|
53 | + $fields_json = array(); |
|
54 | + foreach ($this->getModelVersionInfo()->fieldsOnModelInThisVersion($model) as $field_name => $field_obj) { |
|
55 | + if ($this->getModelVersionInfo()->fieldIsIgnored($field_obj)) { |
|
56 | + continue; |
|
57 | + } |
|
58 | + if ($field_obj instanceof EE_Boolean_Field) { |
|
59 | + $datatype = 'Boolean'; |
|
60 | + } elseif ($field_obj->get_wpdb_data_type() == '%d') { |
|
61 | + $datatype = 'Number'; |
|
62 | + } elseif ($field_name instanceof EE_Serialized_Text_Field) { |
|
63 | + $datatype = 'Object'; |
|
64 | + } else { |
|
65 | + $datatype = 'String'; |
|
66 | + } |
|
67 | + $default_value = ModelDataTranslator::prepareFieldValueForJson( |
|
68 | + $field_obj, |
|
69 | + $field_obj->get_default_value(), |
|
70 | + $this->getModelVersionInfo()->requestedVersion() |
|
71 | + ); |
|
72 | + $field_json = array( |
|
73 | + 'name' => $field_name, |
|
74 | + 'nicename' => wp_specialchars_decode($field_obj->get_nicename(), ENT_QUOTES), |
|
75 | + 'has_rendered_format' => $this->getModelVersionInfo()->fieldHasRenderedFormat($field_obj), |
|
76 | + 'has_pretty_format' => $this->getModelVersionInfo()->fieldHasPrettyFormat($field_obj), |
|
77 | + 'type' => str_replace('EE_', '', get_class($field_obj)), |
|
78 | + 'datatype' => $datatype, |
|
79 | + 'nullable' => $field_obj->is_nullable(), |
|
80 | + 'default' => $default_value, |
|
81 | + 'table_alias' => $field_obj->get_table_alias(), |
|
82 | + 'table_column' => $field_obj->get_table_column(), |
|
83 | + ); |
|
84 | + $fields_json[ $field_json['name'] ] = $field_json; |
|
85 | + } |
|
86 | + $fields_json = array_merge( |
|
87 | + $fields_json, |
|
88 | + $this->getModelVersionInfo()->extraResourcePropertiesForModel($model) |
|
89 | + ); |
|
90 | + $response[ $model_name ]['fields'] = apply_filters( |
|
91 | + 'FHEE__Meta__handle_request_models_meta__fields', |
|
92 | + $fields_json, |
|
93 | + $model |
|
94 | + ); |
|
95 | + $relations_json = array(); |
|
96 | + foreach ($model->relation_settings() as $relation_name => $relation_obj) { |
|
97 | + $relation_json = array( |
|
98 | + 'name' => $relation_name, |
|
99 | + 'type' => str_replace('EE_', '', get_class($relation_obj)), |
|
100 | + 'single' => $relation_obj instanceof EE_Belongs_To_Relation, |
|
101 | + ); |
|
102 | + $relations_json[ $relation_name ] = $relation_json; |
|
103 | + } |
|
104 | + $response[ $model_name ]['relations'] = apply_filters( |
|
105 | + 'FHEE__Meta__handle_request_models_meta__relations', |
|
106 | + $relations_json, |
|
107 | + $model |
|
108 | + ); |
|
109 | + } |
|
110 | + return $response; |
|
111 | + } |
|
112 | 112 | |
113 | 113 | |
114 | - /** |
|
115 | - * Adds EE metadata to the index |
|
116 | - * |
|
117 | - * @param WP_REST_Response $rest_response_obj |
|
118 | - * @return WP_REST_Response |
|
119 | - */ |
|
120 | - public static function filterEeMetadataIntoIndex($rest_response_obj) |
|
121 | - { |
|
122 | - $response_data = $rest_response_obj->get_data(); |
|
123 | - $addons = array(); |
|
124 | - foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | - $addon_json = array( |
|
126 | - 'name' => $addon->name(), |
|
127 | - 'version' => $addon->version(), |
|
128 | - ); |
|
129 | - $addons[ $addon_json['name'] ] = $addon_json; |
|
130 | - } |
|
131 | - $response_data['ee'] = array( |
|
132 | - 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | - // @codingStandardsIgnoreStart |
|
134 | - 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | - // @codingStandardsIgnoreEnd |
|
136 | - 'addons' => $addons, |
|
137 | - 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | - 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | - ); |
|
140 | - $rest_response_obj->set_data($response_data); |
|
141 | - return $rest_response_obj; |
|
142 | - } |
|
114 | + /** |
|
115 | + * Adds EE metadata to the index |
|
116 | + * |
|
117 | + * @param WP_REST_Response $rest_response_obj |
|
118 | + * @return WP_REST_Response |
|
119 | + */ |
|
120 | + public static function filterEeMetadataIntoIndex($rest_response_obj) |
|
121 | + { |
|
122 | + $response_data = $rest_response_obj->get_data(); |
|
123 | + $addons = array(); |
|
124 | + foreach (EE_Registry::instance()->addons as $addon) { |
|
125 | + $addon_json = array( |
|
126 | + 'name' => $addon->name(), |
|
127 | + 'version' => $addon->version(), |
|
128 | + ); |
|
129 | + $addons[ $addon_json['name'] ] = $addon_json; |
|
130 | + } |
|
131 | + $response_data['ee'] = array( |
|
132 | + 'version' => EEM_System_Status::instance()->get_ee_version(), |
|
133 | + // @codingStandardsIgnoreStart |
|
134 | + 'documentation_url' => 'https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API', |
|
135 | + // @codingStandardsIgnoreEnd |
|
136 | + 'addons' => $addons, |
|
137 | + 'maintenance_mode' => EE_Maintenance_Mode::instance()->real_level(), |
|
138 | + 'served_core_versions' => array_keys(EED_Core_Rest_Api::versions_served()), |
|
139 | + ); |
|
140 | + $rest_response_obj->set_data($response_data); |
|
141 | + return $rest_response_obj; |
|
142 | + } |
|
143 | 143 | } |
144 | 144 | |
145 | 145 |
@@ -80,24 +80,24 @@ discard block |
||
80 | 80 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
81 | 81 | */ |
82 | 82 | $input_fields = []; |
83 | - if (! empty($this->args['where'])) { |
|
83 | + if ( ! empty($this->args['where'])) { |
|
84 | 84 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
85 | 85 | |
86 | 86 | // Use the proper operator. |
87 | - if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
87 | + if ( ! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
88 | 88 | $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
89 | 89 | } |
90 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
90 | + if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
91 | 91 | $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
92 | 92 | } |
93 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
93 | + if ( ! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
94 | 94 | $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
95 | 95 | } |
96 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
96 | + if ( ! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
97 | 97 | $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
98 | 98 | } |
99 | 99 | // if event ID is passed but not a ticket ID |
100 | - if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
100 | + if ( ! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
101 | 101 | $event_id = $input_fields['Event.EVT_ID']; |
102 | 102 | // Ensure that this doesn't go to the query. |
103 | 103 | // After all there is no DB relation between event and price |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | /** |
133 | 133 | * Merge the input_fields with the default query_args |
134 | 134 | */ |
135 | - if (! empty($input_fields)) { |
|
135 | + if ( ! empty($input_fields)) { |
|
136 | 136 | $where_params = array_merge($where_params, $input_fields); |
137 | 137 | } |
138 | 138 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $default_prices_params = []; |
142 | 142 | |
143 | 143 | // If default ticket prices should be included. |
144 | - if (! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
144 | + if ( ! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
145 | 145 | $default_ticket_ids = EEM_Ticket::instance()->get_col([ |
146 | 146 | [ |
147 | 147 | 'TKT_is_default' => 1, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ]); |
151 | 151 | |
152 | 152 | // if we have default tickets |
153 | - if (! empty($default_ticket_ids)) { |
|
153 | + if ( ! empty($default_ticket_ids)) { |
|
154 | 154 | $default_prices_params['OR'] = [ |
155 | 155 | 'Ticket.TKT_ID' => ['IN', $default_ticket_ids], |
156 | 156 | ]; |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // If default prices should be included. |
161 | - if (! empty($this->args['where']['includeDefaultPrices'])) { |
|
161 | + if ( ! empty($this->args['where']['includeDefaultPrices'])) { |
|
162 | 162 | $default_prices_params['AND'] = [ |
163 | 163 | 'PRC_deleted' => 0, |
164 | 164 | 'PRC_is_default' => 1, |
165 | 165 | ]; |
166 | 166 | } |
167 | 167 | |
168 | - if (! empty($default_prices_params)) { |
|
168 | + if ( ! empty($default_prices_params)) { |
|
169 | 169 | if (empty($where_params)) { |
170 | 170 | $where_params['OR'] = $default_prices_params; |
171 | 171 | } else { |
@@ -17,222 +17,222 @@ |
||
17 | 17 | */ |
18 | 18 | class PriceConnectionResolver extends AbstractConnectionResolver |
19 | 19 | { |
20 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
21 | - /** |
|
22 | - * @return string |
|
23 | - */ |
|
24 | - public function get_loader_name() |
|
25 | - { |
|
26 | - return 'espresso_price'; |
|
27 | - } |
|
28 | - |
|
29 | - /** |
|
30 | - * @return EEM_Price |
|
31 | - * @throws EE_Error |
|
32 | - * @throws InvalidArgumentException |
|
33 | - * @throws InvalidDataTypeException |
|
34 | - * @throws InvalidInterfaceException |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
38 | - public function get_query() |
|
39 | - { |
|
40 | - return EEM_Price::instance(); |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * Return an array of item IDs from the query |
|
46 | - * |
|
47 | - * @return array |
|
48 | - */ |
|
49 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
50 | - public function get_ids() |
|
51 | - { |
|
52 | - $results = $this->query->get_col($this->query_args); |
|
53 | - |
|
54 | - return ! empty($results) ? $results : []; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
60 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
61 | - * handle batch resolution of the posts. |
|
62 | - * |
|
63 | - * @return array |
|
64 | - * @throws EE_Error |
|
65 | - * @throws InvalidArgumentException |
|
66 | - * @throws ReflectionException |
|
67 | - * @throws InvalidDataTypeException |
|
68 | - * @throws InvalidInterfaceException |
|
69 | - */ |
|
70 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
71 | - public function get_query_args() |
|
72 | - { |
|
73 | - $where_params = []; |
|
74 | - $query_args = []; |
|
75 | - |
|
76 | - $query_args['limit'] = $this->getLimit(); |
|
77 | - |
|
78 | - // Avoid multiple entries by join. |
|
79 | - $query_args['group_by'] = 'PRC_ID'; |
|
80 | - |
|
81 | - $query_args['default_where_conditions'] = 'minimum'; |
|
82 | - |
|
83 | - /** |
|
84 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
85 | - */ |
|
86 | - $input_fields = []; |
|
87 | - if (! empty($this->args['where'])) { |
|
88 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
89 | - |
|
90 | - // Use the proper operator. |
|
91 | - if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
92 | - $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
93 | - } |
|
94 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
95 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
96 | - } |
|
97 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
98 | - $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
99 | - } |
|
100 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
101 | - $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
102 | - } |
|
103 | - // if event ID is passed but not a ticket ID |
|
104 | - if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
105 | - $event_id = $input_fields['Event.EVT_ID']; |
|
106 | - // Ensure that this doesn't go to the query. |
|
107 | - // After all there is no DB relation between event and price |
|
108 | - unset($input_fields['Event.EVT_ID']); |
|
109 | - // get all the datetimeIds of the event |
|
110 | - $event_datetime_ids = EEM_Datetime::instance()->get_col([ |
|
111 | - [ |
|
112 | - 'EVT_ID' => $event_id, |
|
113 | - ], |
|
114 | - 'default_where_conditions' => 'minimum' |
|
115 | - ]); |
|
116 | - // get all the related ticket Ids |
|
117 | - $ticket_ids = EEM_Ticket::instance()->get_col([ |
|
118 | - [ |
|
119 | - 'Datetime.DTT_ID' => ['IN', $event_datetime_ids], |
|
120 | - ], |
|
121 | - 'default_where_conditions' => 'minimum' |
|
122 | - ]); |
|
123 | - |
|
124 | - // add tickets relation to the query |
|
125 | - $input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids]; |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
131 | - */ |
|
132 | - if ($this->source instanceof EE_Ticket) { |
|
133 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Merge the input_fields with the default query_args |
|
138 | - */ |
|
139 | - if (! empty($input_fields)) { |
|
140 | - $where_params = array_merge($where_params, $input_fields); |
|
141 | - } |
|
142 | - |
|
143 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
144 | - |
|
145 | - $default_prices_params = []; |
|
146 | - |
|
147 | - // If default ticket prices should be included. |
|
148 | - if (! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
149 | - $default_ticket_ids = EEM_Ticket::instance()->get_col([ |
|
150 | - [ |
|
151 | - 'TKT_is_default' => 1, |
|
152 | - ], |
|
153 | - 'default_where_conditions' => 'minimum' |
|
154 | - ]); |
|
155 | - |
|
156 | - // if we have default tickets |
|
157 | - if (! empty($default_ticket_ids)) { |
|
158 | - $default_prices_params['OR'] = [ |
|
159 | - 'Ticket.TKT_ID' => ['IN', $default_ticket_ids], |
|
160 | - ]; |
|
161 | - } |
|
162 | - } |
|
163 | - |
|
164 | - // If default prices should be included. |
|
165 | - if (! empty($this->args['where']['includeDefaultPrices'])) { |
|
166 | - $default_prices_params['AND'] = [ |
|
167 | - 'PRC_deleted' => 0, |
|
168 | - 'PRC_is_default' => 1, |
|
169 | - ]; |
|
170 | - } |
|
171 | - |
|
172 | - if (! empty($default_prices_params)) { |
|
173 | - if (empty($where_params)) { |
|
174 | - $where_params['OR'] = $default_prices_params; |
|
175 | - } else { |
|
176 | - $where_params = [ |
|
177 | - 'OR' => [ |
|
178 | - 'OR' => $default_prices_params, |
|
179 | - 'AND' => $where_params, |
|
180 | - ], |
|
181 | - ]; |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - $where_params = apply_filters( |
|
186 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params', |
|
187 | - $where_params, |
|
188 | - $this->source, |
|
189 | - $this->args |
|
190 | - ); |
|
191 | - |
|
192 | - $query_args[] = $where_params; |
|
193 | - |
|
194 | - /** |
|
195 | - * Return the $query_args |
|
196 | - */ |
|
197 | - return apply_filters( |
|
198 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args', |
|
199 | - $query_args, |
|
200 | - $this->source, |
|
201 | - $this->args |
|
202 | - ); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
208 | - * friendly keys. |
|
209 | - * |
|
210 | - * @param array $where_args |
|
211 | - * @return array |
|
212 | - */ |
|
213 | - public function sanitizeInputFields($where_args) |
|
214 | - { |
|
215 | - $arg_mapping = [ |
|
216 | - 'in' => 'PRC_ID', |
|
217 | - 'idIn' => 'PRC_ID', |
|
218 | - 'isDefault' => 'PRC_is_default', |
|
219 | - 'event' => 'Event.EVT_ID', |
|
220 | - 'eventId' => 'Event.EVT_ID', // priority. |
|
221 | - 'ticket' => 'Ticket.TKT_ID', |
|
222 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
223 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
224 | - 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
225 | - 'priceType' => 'Price_Type.PRT_ID', |
|
226 | - 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
227 | - 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
228 | - 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
229 | - 'priceBaseType' => 'Price_Type.PBT_ID', |
|
230 | - 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
231 | - ]; |
|
232 | - return $this->sanitizeWhereArgsForInputFields( |
|
233 | - $where_args, |
|
234 | - $arg_mapping, |
|
235 | - ['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
236 | - ); |
|
237 | - } |
|
20 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
21 | + /** |
|
22 | + * @return string |
|
23 | + */ |
|
24 | + public function get_loader_name() |
|
25 | + { |
|
26 | + return 'espresso_price'; |
|
27 | + } |
|
28 | + |
|
29 | + /** |
|
30 | + * @return EEM_Price |
|
31 | + * @throws EE_Error |
|
32 | + * @throws InvalidArgumentException |
|
33 | + * @throws InvalidDataTypeException |
|
34 | + * @throws InvalidInterfaceException |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
38 | + public function get_query() |
|
39 | + { |
|
40 | + return EEM_Price::instance(); |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * Return an array of item IDs from the query |
|
46 | + * |
|
47 | + * @return array |
|
48 | + */ |
|
49 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
50 | + public function get_ids() |
|
51 | + { |
|
52 | + $results = $this->query->get_col($this->query_args); |
|
53 | + |
|
54 | + return ! empty($results) ? $results : []; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
60 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
61 | + * handle batch resolution of the posts. |
|
62 | + * |
|
63 | + * @return array |
|
64 | + * @throws EE_Error |
|
65 | + * @throws InvalidArgumentException |
|
66 | + * @throws ReflectionException |
|
67 | + * @throws InvalidDataTypeException |
|
68 | + * @throws InvalidInterfaceException |
|
69 | + */ |
|
70 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
71 | + public function get_query_args() |
|
72 | + { |
|
73 | + $where_params = []; |
|
74 | + $query_args = []; |
|
75 | + |
|
76 | + $query_args['limit'] = $this->getLimit(); |
|
77 | + |
|
78 | + // Avoid multiple entries by join. |
|
79 | + $query_args['group_by'] = 'PRC_ID'; |
|
80 | + |
|
81 | + $query_args['default_where_conditions'] = 'minimum'; |
|
82 | + |
|
83 | + /** |
|
84 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
85 | + */ |
|
86 | + $input_fields = []; |
|
87 | + if (! empty($this->args['where'])) { |
|
88 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
89 | + |
|
90 | + // Use the proper operator. |
|
91 | + if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
92 | + $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
93 | + } |
|
94 | + if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
95 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
96 | + } |
|
97 | + if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
98 | + $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
99 | + } |
|
100 | + if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
101 | + $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
102 | + } |
|
103 | + // if event ID is passed but not a ticket ID |
|
104 | + if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
105 | + $event_id = $input_fields['Event.EVT_ID']; |
|
106 | + // Ensure that this doesn't go to the query. |
|
107 | + // After all there is no DB relation between event and price |
|
108 | + unset($input_fields['Event.EVT_ID']); |
|
109 | + // get all the datetimeIds of the event |
|
110 | + $event_datetime_ids = EEM_Datetime::instance()->get_col([ |
|
111 | + [ |
|
112 | + 'EVT_ID' => $event_id, |
|
113 | + ], |
|
114 | + 'default_where_conditions' => 'minimum' |
|
115 | + ]); |
|
116 | + // get all the related ticket Ids |
|
117 | + $ticket_ids = EEM_Ticket::instance()->get_col([ |
|
118 | + [ |
|
119 | + 'Datetime.DTT_ID' => ['IN', $event_datetime_ids], |
|
120 | + ], |
|
121 | + 'default_where_conditions' => 'minimum' |
|
122 | + ]); |
|
123 | + |
|
124 | + // add tickets relation to the query |
|
125 | + $input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids]; |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
131 | + */ |
|
132 | + if ($this->source instanceof EE_Ticket) { |
|
133 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Merge the input_fields with the default query_args |
|
138 | + */ |
|
139 | + if (! empty($input_fields)) { |
|
140 | + $where_params = array_merge($where_params, $input_fields); |
|
141 | + } |
|
142 | + |
|
143 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
144 | + |
|
145 | + $default_prices_params = []; |
|
146 | + |
|
147 | + // If default ticket prices should be included. |
|
148 | + if (! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
149 | + $default_ticket_ids = EEM_Ticket::instance()->get_col([ |
|
150 | + [ |
|
151 | + 'TKT_is_default' => 1, |
|
152 | + ], |
|
153 | + 'default_where_conditions' => 'minimum' |
|
154 | + ]); |
|
155 | + |
|
156 | + // if we have default tickets |
|
157 | + if (! empty($default_ticket_ids)) { |
|
158 | + $default_prices_params['OR'] = [ |
|
159 | + 'Ticket.TKT_ID' => ['IN', $default_ticket_ids], |
|
160 | + ]; |
|
161 | + } |
|
162 | + } |
|
163 | + |
|
164 | + // If default prices should be included. |
|
165 | + if (! empty($this->args['where']['includeDefaultPrices'])) { |
|
166 | + $default_prices_params['AND'] = [ |
|
167 | + 'PRC_deleted' => 0, |
|
168 | + 'PRC_is_default' => 1, |
|
169 | + ]; |
|
170 | + } |
|
171 | + |
|
172 | + if (! empty($default_prices_params)) { |
|
173 | + if (empty($where_params)) { |
|
174 | + $where_params['OR'] = $default_prices_params; |
|
175 | + } else { |
|
176 | + $where_params = [ |
|
177 | + 'OR' => [ |
|
178 | + 'OR' => $default_prices_params, |
|
179 | + 'AND' => $where_params, |
|
180 | + ], |
|
181 | + ]; |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + $where_params = apply_filters( |
|
186 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params', |
|
187 | + $where_params, |
|
188 | + $this->source, |
|
189 | + $this->args |
|
190 | + ); |
|
191 | + |
|
192 | + $query_args[] = $where_params; |
|
193 | + |
|
194 | + /** |
|
195 | + * Return the $query_args |
|
196 | + */ |
|
197 | + return apply_filters( |
|
198 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args', |
|
199 | + $query_args, |
|
200 | + $this->source, |
|
201 | + $this->args |
|
202 | + ); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
208 | + * friendly keys. |
|
209 | + * |
|
210 | + * @param array $where_args |
|
211 | + * @return array |
|
212 | + */ |
|
213 | + public function sanitizeInputFields($where_args) |
|
214 | + { |
|
215 | + $arg_mapping = [ |
|
216 | + 'in' => 'PRC_ID', |
|
217 | + 'idIn' => 'PRC_ID', |
|
218 | + 'isDefault' => 'PRC_is_default', |
|
219 | + 'event' => 'Event.EVT_ID', |
|
220 | + 'eventId' => 'Event.EVT_ID', // priority. |
|
221 | + 'ticket' => 'Ticket.TKT_ID', |
|
222 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
223 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
224 | + 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
225 | + 'priceType' => 'Price_Type.PRT_ID', |
|
226 | + 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
227 | + 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
228 | + 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
229 | + 'priceBaseType' => 'Price_Type.PBT_ID', |
|
230 | + 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
231 | + ]; |
|
232 | + return $this->sanitizeWhereArgsForInputFields( |
|
233 | + $where_args, |
|
234 | + $arg_mapping, |
|
235 | + ['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
236 | + ); |
|
237 | + } |
|
238 | 238 | } |