@@ -7,7 +7,6 @@ |
||
7 | 7 | use EventEspresso\core\domain\services\graphql\connection_resolvers\DatetimeConnectionResolver; |
8 | 8 | use EventEspresso\core\services\graphql\connections\ConnectionBase; |
9 | 9 | use Exception; |
10 | -use WPGraphQL\Type\WPObjectType; |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * Class EventDatetimesConnection |
@@ -21,127 +21,127 @@ |
||
21 | 21 | { |
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * DatetimeConnection constructor. |
|
26 | - * |
|
27 | - * @param EEM_Datetime $model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Datetime $model) |
|
30 | - { |
|
31 | - $this->model = $model; |
|
32 | - } |
|
24 | + /** |
|
25 | + * DatetimeConnection constructor. |
|
26 | + * |
|
27 | + * @param EEM_Datetime $model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Datetime $model) |
|
30 | + { |
|
31 | + $this->model = $model; |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * @return array |
|
37 | - * @since $VID:$ |
|
38 | - */ |
|
39 | - public function config() |
|
40 | - { |
|
41 | - return [ |
|
42 | - 'fromType' => $this->namespace . 'Event', |
|
43 | - 'toType' => $this->namespace . 'Datetime', |
|
44 | - 'fromFieldName' => 'datetimes', |
|
45 | - 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
|
46 | - 'connectionArgs' => self::get_connection_args(), |
|
47 | - 'resolve' => [$this, 'resolveConnection'], |
|
48 | - 'resolveNode' => [$this, 'resolveNode'] |
|
49 | - ]; |
|
50 | - } |
|
35 | + /** |
|
36 | + * @return array |
|
37 | + * @since $VID:$ |
|
38 | + */ |
|
39 | + public function config() |
|
40 | + { |
|
41 | + return [ |
|
42 | + 'fromType' => $this->namespace . 'Event', |
|
43 | + 'toType' => $this->namespace . 'Datetime', |
|
44 | + 'fromFieldName' => 'datetimes', |
|
45 | + 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
|
46 | + 'connectionArgs' => self::get_connection_args(), |
|
47 | + 'resolve' => [$this, 'resolveConnection'], |
|
48 | + 'resolveNode' => [$this, 'resolveNode'] |
|
49 | + ]; |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @param $entity |
|
55 | - * @param $args |
|
56 | - * @param $context |
|
57 | - * @param $info |
|
58 | - * @return array |
|
59 | - * @throws Exception |
|
60 | - * @since $VID:$ |
|
61 | - */ |
|
62 | - public function resolveConnection($entity, $args, $context, $info) |
|
63 | - { |
|
64 | - $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
65 | - return $resolver->get_connection(); |
|
66 | - } |
|
53 | + /** |
|
54 | + * @param $entity |
|
55 | + * @param $args |
|
56 | + * @param $context |
|
57 | + * @param $info |
|
58 | + * @return array |
|
59 | + * @throws Exception |
|
60 | + * @since $VID:$ |
|
61 | + */ |
|
62 | + public function resolveConnection($entity, $args, $context, $info) |
|
63 | + { |
|
64 | + $resolver = new DatetimeConnectionResolver($entity, $args, $context, $info); |
|
65 | + return $resolver->get_connection(); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * @param $id |
|
71 | - * @param $args |
|
72 | - * @param $context |
|
73 | - * @param $info |
|
74 | - * @return EE_Base_Class |
|
75 | - * @since $VID:$ |
|
76 | - */ |
|
77 | - public function resolveNode($id, $args, $context, $info) |
|
78 | - { |
|
79 | - return $this->model->get_one_by_ID($id); |
|
80 | - } |
|
69 | + /** |
|
70 | + * @param $id |
|
71 | + * @param $args |
|
72 | + * @param $context |
|
73 | + * @param $info |
|
74 | + * @return EE_Base_Class |
|
75 | + * @since $VID:$ |
|
76 | + */ |
|
77 | + public function resolveNode($id, $args, $context, $info) |
|
78 | + { |
|
79 | + return $this->model->get_one_by_ID($id); |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Given an optional array of args, this returns the args to be used in the connection |
|
84 | - * |
|
85 | - * @access public |
|
86 | - * @param array $args The args to modify the defaults |
|
87 | - * |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
91 | - public static function get_connection_args($args = []) |
|
92 | - { |
|
93 | - return array_merge( |
|
94 | - [ |
|
95 | - 'orderby' => [ |
|
96 | - 'type' => ['list_of' => 'DatetimesConnectionOrderbyInput'], |
|
97 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
98 | - ], |
|
99 | - 'event' => [ |
|
100 | - 'type' => 'ID', |
|
101 | - 'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), |
|
102 | - ], |
|
103 | - 'eventIn' => [ |
|
104 | - 'type' => ['list_of' => 'ID'], |
|
105 | - 'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), |
|
106 | - ], |
|
107 | - 'eventId' => [ |
|
108 | - 'type' => 'Int', |
|
109 | - 'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), |
|
110 | - ], |
|
111 | - 'eventIdIn' => [ |
|
112 | - 'type' => ['list_of' => 'Int'], |
|
113 | - 'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), |
|
114 | - ], |
|
115 | - 'ticket' => [ |
|
116 | - 'type' => 'ID', |
|
117 | - 'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), |
|
118 | - ], |
|
119 | - 'ticketIn' => [ |
|
120 | - 'type' => ['list_of' => 'ID'], |
|
121 | - 'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), |
|
122 | - ], |
|
123 | - 'ticketId' => [ |
|
124 | - 'type' => 'Int', |
|
125 | - 'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), |
|
126 | - ], |
|
127 | - 'ticketIdIn' => [ |
|
128 | - 'type' => ['list_of' => 'Int'], |
|
129 | - 'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), |
|
130 | - ], |
|
131 | - 'upcoming' => [ |
|
132 | - 'type' => 'Boolean', |
|
133 | - 'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), |
|
134 | - ], |
|
135 | - 'active' => [ |
|
136 | - 'type' => 'Boolean', |
|
137 | - 'description' => esc_html__('Datetimes which are active.', 'event_espresso'), |
|
138 | - ], |
|
139 | - 'expired' => [ |
|
140 | - 'type' => 'Boolean', |
|
141 | - 'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), |
|
142 | - ], |
|
143 | - ], |
|
144 | - $args |
|
145 | - ); |
|
146 | - } |
|
82 | + /** |
|
83 | + * Given an optional array of args, this returns the args to be used in the connection |
|
84 | + * |
|
85 | + * @access public |
|
86 | + * @param array $args The args to modify the defaults |
|
87 | + * |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
91 | + public static function get_connection_args($args = []) |
|
92 | + { |
|
93 | + return array_merge( |
|
94 | + [ |
|
95 | + 'orderby' => [ |
|
96 | + 'type' => ['list_of' => 'DatetimesConnectionOrderbyInput'], |
|
97 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
98 | + ], |
|
99 | + 'event' => [ |
|
100 | + 'type' => 'ID', |
|
101 | + 'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), |
|
102 | + ], |
|
103 | + 'eventIn' => [ |
|
104 | + 'type' => ['list_of' => 'ID'], |
|
105 | + 'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), |
|
106 | + ], |
|
107 | + 'eventId' => [ |
|
108 | + 'type' => 'Int', |
|
109 | + 'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), |
|
110 | + ], |
|
111 | + 'eventIdIn' => [ |
|
112 | + 'type' => ['list_of' => 'Int'], |
|
113 | + 'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), |
|
114 | + ], |
|
115 | + 'ticket' => [ |
|
116 | + 'type' => 'ID', |
|
117 | + 'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), |
|
118 | + ], |
|
119 | + 'ticketIn' => [ |
|
120 | + 'type' => ['list_of' => 'ID'], |
|
121 | + 'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), |
|
122 | + ], |
|
123 | + 'ticketId' => [ |
|
124 | + 'type' => 'Int', |
|
125 | + 'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), |
|
126 | + ], |
|
127 | + 'ticketIdIn' => [ |
|
128 | + 'type' => ['list_of' => 'Int'], |
|
129 | + 'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), |
|
130 | + ], |
|
131 | + 'upcoming' => [ |
|
132 | + 'type' => 'Boolean', |
|
133 | + 'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), |
|
134 | + ], |
|
135 | + 'active' => [ |
|
136 | + 'type' => 'Boolean', |
|
137 | + 'description' => esc_html__('Datetimes which are active.', 'event_espresso'), |
|
138 | + ], |
|
139 | + 'expired' => [ |
|
140 | + 'type' => 'Boolean', |
|
141 | + 'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), |
|
142 | + ], |
|
143 | + ], |
|
144 | + $args |
|
145 | + ); |
|
146 | + } |
|
147 | 147 | } |
@@ -39,8 +39,8 @@ |
||
39 | 39 | public function config() |
40 | 40 | { |
41 | 41 | return [ |
42 | - 'fromType' => $this->namespace . 'Event', |
|
43 | - 'toType' => $this->namespace . 'Datetime', |
|
42 | + 'fromType' => $this->namespace.'Event', |
|
43 | + 'toType' => $this->namespace.'Datetime', |
|
44 | 44 | 'fromFieldName' => 'datetimes', |
45 | 45 | 'connectionTypeName' => "{$this->namespace}EventDatetimesConnection", |
46 | 46 | 'connectionArgs' => self::get_connection_args(), |
@@ -40,266 +40,266 @@ discard block |
||
40 | 40 | class AdvancedEditorEntityData |
41 | 41 | { |
42 | 42 | |
43 | - /** |
|
44 | - * @var string $namespace The graphql namespace/prefix. |
|
45 | - */ |
|
46 | - protected $namespace = 'Espresso'; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var EE_Event |
|
50 | - */ |
|
51 | - protected $event; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var RestApiSpoofer |
|
55 | - */ |
|
56 | - protected $spoofer; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var EE_Admin_Config |
|
60 | - */ |
|
61 | - protected $admin_config; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var EEM_Datetime $datetime_model |
|
65 | - */ |
|
66 | - protected $datetime_model; |
|
67 | - |
|
68 | - /** |
|
69 | - * @var EEM_Event $event_model |
|
70 | - */ |
|
71 | - protected $event_model; |
|
72 | - |
|
73 | - /** |
|
74 | - * @var EEM_Price $price_model |
|
75 | - */ |
|
76 | - protected $price_model; |
|
77 | - |
|
78 | - /** |
|
79 | - * @var EEM_Price_Type $price_type_model |
|
80 | - */ |
|
81 | - protected $price_type_model; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var EEM_Ticket $ticket_model |
|
85 | - */ |
|
86 | - protected $ticket_model; |
|
87 | - /** |
|
88 | - * @var EEM_Venue $venue_model |
|
89 | - */ |
|
90 | - protected $venue_model; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * AdvancedEditorAdminForm constructor. |
|
95 | - * |
|
96 | - * @param EE_Event $event |
|
97 | - * @param RestApiSpoofer $spoofer |
|
98 | - * @param EE_Admin_Config $admin_config |
|
99 | - * @param EEM_Datetime $datetime_model |
|
100 | - * @param EEM_Event $event_model |
|
101 | - * @param EEM_Price $price_model |
|
102 | - * @param EEM_Price_Type $price_type_model |
|
103 | - * @param EEM_Ticket $ticket_model |
|
104 | - * @param EEM_Venue $venue_model |
|
105 | - */ |
|
106 | - public function __construct( |
|
107 | - EE_Event $event, |
|
108 | - RestApiSpoofer $spoofer, |
|
109 | - EE_Admin_Config $admin_config, |
|
110 | - EEM_Datetime $datetime_model, |
|
111 | - EEM_Event $event_model, |
|
112 | - EEM_Price $price_model, |
|
113 | - EEM_Price_Type $price_type_model, |
|
114 | - EEM_Ticket $ticket_model, |
|
115 | - EEM_Venue $venue_model |
|
116 | - ) { |
|
117 | - $this->event = $event; |
|
118 | - $this->admin_config = $admin_config; |
|
119 | - $this->spoofer = $spoofer; |
|
120 | - $this->datetime_model = $datetime_model; |
|
121 | - $this->event_model = $event_model; |
|
122 | - $this->price_model = $price_model; |
|
123 | - $this->price_type_model = $price_type_model; |
|
124 | - $this->ticket_model = $ticket_model; |
|
125 | - $this->venue_model = $venue_model; |
|
126 | - add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - * @throws ModelConfigurationException |
|
136 | - * @throws ReflectionException |
|
137 | - * @throws RestException |
|
138 | - * @throws RestPasswordIncorrectException |
|
139 | - * @throws RestPasswordRequiredException |
|
140 | - * @throws UnexpectedEntityException |
|
141 | - * @throws DomainException |
|
142 | - * @since $VID:$ |
|
143 | - */ |
|
144 | - public function loadScriptsStyles() |
|
145 | - { |
|
146 | - if ($this->admin_config->useAdvancedEditor()) { |
|
147 | - $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
148 | - if (! $eventId) { |
|
149 | - global $post; |
|
150 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
151 | - $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
152 | - ? $post->ID |
|
153 | - : $eventId; |
|
154 | - } |
|
155 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
156 | - $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
157 | - if ($eventId) { |
|
158 | - $data = $this->getAllEventData($eventId); |
|
159 | - $data = wp_json_encode($data); |
|
160 | - $GQLdata = $this->getGraphQLData($eventId); |
|
161 | - $GQLdata = wp_json_encode($GQLdata); |
|
162 | - add_action( |
|
163 | - 'admin_footer', |
|
164 | - static function () use ($data, $graphqlEndpoint) { |
|
165 | - wp_add_inline_script( |
|
166 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
167 | - " |
|
43 | + /** |
|
44 | + * @var string $namespace The graphql namespace/prefix. |
|
45 | + */ |
|
46 | + protected $namespace = 'Espresso'; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var EE_Event |
|
50 | + */ |
|
51 | + protected $event; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var RestApiSpoofer |
|
55 | + */ |
|
56 | + protected $spoofer; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var EE_Admin_Config |
|
60 | + */ |
|
61 | + protected $admin_config; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var EEM_Datetime $datetime_model |
|
65 | + */ |
|
66 | + protected $datetime_model; |
|
67 | + |
|
68 | + /** |
|
69 | + * @var EEM_Event $event_model |
|
70 | + */ |
|
71 | + protected $event_model; |
|
72 | + |
|
73 | + /** |
|
74 | + * @var EEM_Price $price_model |
|
75 | + */ |
|
76 | + protected $price_model; |
|
77 | + |
|
78 | + /** |
|
79 | + * @var EEM_Price_Type $price_type_model |
|
80 | + */ |
|
81 | + protected $price_type_model; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var EEM_Ticket $ticket_model |
|
85 | + */ |
|
86 | + protected $ticket_model; |
|
87 | + /** |
|
88 | + * @var EEM_Venue $venue_model |
|
89 | + */ |
|
90 | + protected $venue_model; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * AdvancedEditorAdminForm constructor. |
|
95 | + * |
|
96 | + * @param EE_Event $event |
|
97 | + * @param RestApiSpoofer $spoofer |
|
98 | + * @param EE_Admin_Config $admin_config |
|
99 | + * @param EEM_Datetime $datetime_model |
|
100 | + * @param EEM_Event $event_model |
|
101 | + * @param EEM_Price $price_model |
|
102 | + * @param EEM_Price_Type $price_type_model |
|
103 | + * @param EEM_Ticket $ticket_model |
|
104 | + * @param EEM_Venue $venue_model |
|
105 | + */ |
|
106 | + public function __construct( |
|
107 | + EE_Event $event, |
|
108 | + RestApiSpoofer $spoofer, |
|
109 | + EE_Admin_Config $admin_config, |
|
110 | + EEM_Datetime $datetime_model, |
|
111 | + EEM_Event $event_model, |
|
112 | + EEM_Price $price_model, |
|
113 | + EEM_Price_Type $price_type_model, |
|
114 | + EEM_Ticket $ticket_model, |
|
115 | + EEM_Venue $venue_model |
|
116 | + ) { |
|
117 | + $this->event = $event; |
|
118 | + $this->admin_config = $admin_config; |
|
119 | + $this->spoofer = $spoofer; |
|
120 | + $this->datetime_model = $datetime_model; |
|
121 | + $this->event_model = $event_model; |
|
122 | + $this->price_model = $price_model; |
|
123 | + $this->price_type_model = $price_type_model; |
|
124 | + $this->ticket_model = $ticket_model; |
|
125 | + $this->venue_model = $venue_model; |
|
126 | + add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + * @throws ModelConfigurationException |
|
136 | + * @throws ReflectionException |
|
137 | + * @throws RestException |
|
138 | + * @throws RestPasswordIncorrectException |
|
139 | + * @throws RestPasswordRequiredException |
|
140 | + * @throws UnexpectedEntityException |
|
141 | + * @throws DomainException |
|
142 | + * @since $VID:$ |
|
143 | + */ |
|
144 | + public function loadScriptsStyles() |
|
145 | + { |
|
146 | + if ($this->admin_config->useAdvancedEditor()) { |
|
147 | + $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
148 | + if (! $eventId) { |
|
149 | + global $post; |
|
150 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
151 | + $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
152 | + ? $post->ID |
|
153 | + : $eventId; |
|
154 | + } |
|
155 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
156 | + $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
157 | + if ($eventId) { |
|
158 | + $data = $this->getAllEventData($eventId); |
|
159 | + $data = wp_json_encode($data); |
|
160 | + $GQLdata = $this->getGraphQLData($eventId); |
|
161 | + $GQLdata = wp_json_encode($GQLdata); |
|
162 | + add_action( |
|
163 | + 'admin_footer', |
|
164 | + static function () use ($data, $graphqlEndpoint) { |
|
165 | + wp_add_inline_script( |
|
166 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
167 | + " |
|
168 | 168 | var eeEditorEventData={$data}; |
169 | 169 | var graphqlEndpoint='{$graphqlEndpoint}'; |
170 | 170 | ", |
171 | - 'before' |
|
172 | - ); |
|
173 | - } |
|
174 | - ); |
|
175 | - add_action( |
|
176 | - 'admin_footer', |
|
177 | - static function () use ($data, $GQLdata, $graphqlEndpoint) { |
|
178 | - wp_add_inline_script( |
|
179 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
180 | - " |
|
171 | + 'before' |
|
172 | + ); |
|
173 | + } |
|
174 | + ); |
|
175 | + add_action( |
|
176 | + 'admin_footer', |
|
177 | + static function () use ($data, $GQLdata, $graphqlEndpoint) { |
|
178 | + wp_add_inline_script( |
|
179 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
180 | + " |
|
181 | 181 | var eeEditorEventData={$data}; |
182 | 182 | var eeEditorGQLData={$GQLdata}; |
183 | 183 | var graphqlEndpoint='{$graphqlEndpoint}'; |
184 | 184 | ", |
185 | - 'before' |
|
186 | - ); |
|
187 | - } |
|
188 | - ); |
|
189 | - } |
|
190 | - } |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - /** |
|
195 | - * @param int $eventId |
|
196 | - * @return array |
|
197 | - * @throws DomainException |
|
198 | - * @throws EE_Error |
|
199 | - * @throws InvalidArgumentException |
|
200 | - * @throws InvalidDataTypeException |
|
201 | - * @throws InvalidInterfaceException |
|
202 | - * @throws ModelConfigurationException |
|
203 | - * @throws ReflectionException |
|
204 | - * @throws RestException |
|
205 | - * @throws RestPasswordIncorrectException |
|
206 | - * @throws RestPasswordRequiredException |
|
207 | - * @throws UnexpectedEntityException |
|
208 | - * @since $VID:$ |
|
209 | - */ |
|
210 | - protected function getEventDates($eventId) |
|
211 | - { |
|
212 | - return $this->spoofer->getApiResults( |
|
213 | - $this->datetime_model, |
|
214 | - [ |
|
215 | - [ |
|
216 | - 'EVT_ID' => $eventId, |
|
217 | - 'DTT_deleted' => ['IN', [true, false]] |
|
218 | - ] |
|
219 | - ] |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * @param int $eventId |
|
226 | - * @param array $eventDates |
|
227 | - * @throws DomainException |
|
228 | - * @throws EE_Error |
|
229 | - * @throws InvalidArgumentException |
|
230 | - * @throws InvalidDataTypeException |
|
231 | - * @throws InvalidInterfaceException |
|
232 | - * @throws ModelConfigurationException |
|
233 | - * @throws ReflectionException |
|
234 | - * @throws RestException |
|
235 | - * @throws RestPasswordIncorrectException |
|
236 | - * @throws RestPasswordRequiredException |
|
237 | - * @throws UnexpectedEntityException |
|
238 | - * @since $VID:$ |
|
239 | - */ |
|
240 | - protected function addDefaultEntities($eventId, array $eventDates = []) |
|
241 | - { |
|
242 | - $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
243 | - if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
244 | - $default_date = $default_dates[0]; |
|
245 | - $default_date->save(); |
|
246 | - $default_date->_add_relation_to($eventId, 'Event'); |
|
247 | - $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
248 | - $default_prices = $this->price_model->get_all_default_prices(); |
|
249 | - foreach ($default_tickets as $default_ticket) { |
|
250 | - $default_ticket->save(); |
|
251 | - $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
252 | - foreach ($default_prices as $default_price) { |
|
253 | - $default_price->save(); |
|
254 | - $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
255 | - } |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
259 | - |
|
260 | - |
|
261 | - /** |
|
262 | - * @param int $eventId |
|
263 | - * @return array |
|
264 | - * @since $VID:$ |
|
265 | - */ |
|
266 | - protected function getGraphQLData($eventId) |
|
267 | - { |
|
268 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
269 | - |
|
270 | - if (! empty($datetimes['nodes'])) { |
|
271 | - $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
272 | - |
|
273 | - if (! empty($datetimeIn)) { |
|
274 | - $tickets = $this->getGraphQLTickets($datetimeIn); |
|
275 | - } |
|
276 | - } |
|
277 | - |
|
278 | - if (! empty($tickets['nodes'])) { |
|
279 | - $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
280 | - |
|
281 | - if (! empty($ticketIn)) { |
|
282 | - $prices = $this->getGraphQLPrices($ticketIn); |
|
283 | - } |
|
284 | - } |
|
285 | - |
|
286 | - $priceTypes = $this->getGraphQLPriceTypes(); |
|
287 | - |
|
288 | - $relations = $this->getRelationalData($eventId); |
|
289 | - |
|
290 | - return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @param int $eventId |
|
296 | - * @return array|null |
|
297 | - * @since $VID:$ |
|
298 | - */ |
|
299 | - protected function getGraphQLDatetimes($eventId) |
|
300 | - { |
|
301 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
302 | - $query = <<<QUERY |
|
185 | + 'before' |
|
186 | + ); |
|
187 | + } |
|
188 | + ); |
|
189 | + } |
|
190 | + } |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + /** |
|
195 | + * @param int $eventId |
|
196 | + * @return array |
|
197 | + * @throws DomainException |
|
198 | + * @throws EE_Error |
|
199 | + * @throws InvalidArgumentException |
|
200 | + * @throws InvalidDataTypeException |
|
201 | + * @throws InvalidInterfaceException |
|
202 | + * @throws ModelConfigurationException |
|
203 | + * @throws ReflectionException |
|
204 | + * @throws RestException |
|
205 | + * @throws RestPasswordIncorrectException |
|
206 | + * @throws RestPasswordRequiredException |
|
207 | + * @throws UnexpectedEntityException |
|
208 | + * @since $VID:$ |
|
209 | + */ |
|
210 | + protected function getEventDates($eventId) |
|
211 | + { |
|
212 | + return $this->spoofer->getApiResults( |
|
213 | + $this->datetime_model, |
|
214 | + [ |
|
215 | + [ |
|
216 | + 'EVT_ID' => $eventId, |
|
217 | + 'DTT_deleted' => ['IN', [true, false]] |
|
218 | + ] |
|
219 | + ] |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * @param int $eventId |
|
226 | + * @param array $eventDates |
|
227 | + * @throws DomainException |
|
228 | + * @throws EE_Error |
|
229 | + * @throws InvalidArgumentException |
|
230 | + * @throws InvalidDataTypeException |
|
231 | + * @throws InvalidInterfaceException |
|
232 | + * @throws ModelConfigurationException |
|
233 | + * @throws ReflectionException |
|
234 | + * @throws RestException |
|
235 | + * @throws RestPasswordIncorrectException |
|
236 | + * @throws RestPasswordRequiredException |
|
237 | + * @throws UnexpectedEntityException |
|
238 | + * @since $VID:$ |
|
239 | + */ |
|
240 | + protected function addDefaultEntities($eventId, array $eventDates = []) |
|
241 | + { |
|
242 | + $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
243 | + if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
244 | + $default_date = $default_dates[0]; |
|
245 | + $default_date->save(); |
|
246 | + $default_date->_add_relation_to($eventId, 'Event'); |
|
247 | + $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
248 | + $default_prices = $this->price_model->get_all_default_prices(); |
|
249 | + foreach ($default_tickets as $default_ticket) { |
|
250 | + $default_ticket->save(); |
|
251 | + $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
252 | + foreach ($default_prices as $default_price) { |
|
253 | + $default_price->save(); |
|
254 | + $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
255 | + } |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | + |
|
260 | + |
|
261 | + /** |
|
262 | + * @param int $eventId |
|
263 | + * @return array |
|
264 | + * @since $VID:$ |
|
265 | + */ |
|
266 | + protected function getGraphQLData($eventId) |
|
267 | + { |
|
268 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
269 | + |
|
270 | + if (! empty($datetimes['nodes'])) { |
|
271 | + $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
272 | + |
|
273 | + if (! empty($datetimeIn)) { |
|
274 | + $tickets = $this->getGraphQLTickets($datetimeIn); |
|
275 | + } |
|
276 | + } |
|
277 | + |
|
278 | + if (! empty($tickets['nodes'])) { |
|
279 | + $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
280 | + |
|
281 | + if (! empty($ticketIn)) { |
|
282 | + $prices = $this->getGraphQLPrices($ticketIn); |
|
283 | + } |
|
284 | + } |
|
285 | + |
|
286 | + $priceTypes = $this->getGraphQLPriceTypes(); |
|
287 | + |
|
288 | + $relations = $this->getRelationalData($eventId); |
|
289 | + |
|
290 | + return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @param int $eventId |
|
296 | + * @return array|null |
|
297 | + * @since $VID:$ |
|
298 | + */ |
|
299 | + protected function getGraphQLDatetimes($eventId) |
|
300 | + { |
|
301 | + $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
302 | + $query = <<<QUERY |
|
303 | 303 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
304 | 304 | {$field_key}(where: \$where) { |
305 | 305 | nodes { |
@@ -325,31 +325,31 @@ discard block |
||
325 | 325 | } |
326 | 326 | } |
327 | 327 | QUERY; |
328 | - $data = [ |
|
329 | - 'operation_name' => 'GET_DATETIMES', |
|
330 | - 'variables' => [ |
|
331 | - 'first' => 50, |
|
332 | - 'where' => [ |
|
333 | - 'eventId' => $eventId, |
|
334 | - ], |
|
335 | - ], |
|
336 | - 'query' => $query, |
|
337 | - ]; |
|
338 | - |
|
339 | - $responseData = $this->makeGraphQLRequest($data); |
|
340 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * @param array $datetimeIn |
|
346 | - * @return array|null |
|
347 | - * @since $VID:$ |
|
348 | - */ |
|
349 | - protected function getGraphQLTickets(array $datetimeIn) |
|
350 | - { |
|
351 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
352 | - $query = <<<QUERY |
|
328 | + $data = [ |
|
329 | + 'operation_name' => 'GET_DATETIMES', |
|
330 | + 'variables' => [ |
|
331 | + 'first' => 50, |
|
332 | + 'where' => [ |
|
333 | + 'eventId' => $eventId, |
|
334 | + ], |
|
335 | + ], |
|
336 | + 'query' => $query, |
|
337 | + ]; |
|
338 | + |
|
339 | + $responseData = $this->makeGraphQLRequest($data); |
|
340 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * @param array $datetimeIn |
|
346 | + * @return array|null |
|
347 | + * @since $VID:$ |
|
348 | + */ |
|
349 | + protected function getGraphQLTickets(array $datetimeIn) |
|
350 | + { |
|
351 | + $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
352 | + $query = <<<QUERY |
|
353 | 353 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
354 | 354 | {$field_key}(where: \$where) { |
355 | 355 | nodes { |
@@ -378,30 +378,30 @@ discard block |
||
378 | 378 | } |
379 | 379 | } |
380 | 380 | QUERY; |
381 | - $data = [ |
|
382 | - 'operation_name' => 'GET_TICKETS', |
|
383 | - 'variables' => [ |
|
384 | - 'where' => [ |
|
385 | - 'datetimeIn' => $datetimeIn, |
|
386 | - ], |
|
387 | - ], |
|
388 | - 'query' => $query, |
|
389 | - ]; |
|
390 | - |
|
391 | - $responseData = $this->makeGraphQLRequest($data); |
|
392 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * @param array $ticketIn |
|
398 | - * @return array|null |
|
399 | - * @since $VID:$ |
|
400 | - */ |
|
401 | - protected function getGraphQLPrices(array $ticketIn) |
|
402 | - { |
|
403 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
404 | - $query = <<<QUERY |
|
381 | + $data = [ |
|
382 | + 'operation_name' => 'GET_TICKETS', |
|
383 | + 'variables' => [ |
|
384 | + 'where' => [ |
|
385 | + 'datetimeIn' => $datetimeIn, |
|
386 | + ], |
|
387 | + ], |
|
388 | + 'query' => $query, |
|
389 | + ]; |
|
390 | + |
|
391 | + $responseData = $this->makeGraphQLRequest($data); |
|
392 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * @param array $ticketIn |
|
398 | + * @return array|null |
|
399 | + * @since $VID:$ |
|
400 | + */ |
|
401 | + protected function getGraphQLPrices(array $ticketIn) |
|
402 | + { |
|
403 | + $field_key = lcfirst($this->namespace) . 'Prices'; |
|
404 | + $query = <<<QUERY |
|
405 | 405 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
406 | 406 | {$field_key}(where: \$where) { |
407 | 407 | nodes { |
@@ -425,29 +425,29 @@ discard block |
||
425 | 425 | } |
426 | 426 | } |
427 | 427 | QUERY; |
428 | - $data = [ |
|
429 | - 'operation_name' => 'GET_PRICES', |
|
430 | - 'variables' => [ |
|
431 | - 'where' => [ |
|
432 | - 'ticketIn' => $ticketIn, |
|
433 | - ], |
|
434 | - ], |
|
435 | - 'query' => $query, |
|
436 | - ]; |
|
437 | - |
|
438 | - $responseData = $this->makeGraphQLRequest($data); |
|
439 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * @return array|null |
|
445 | - * @since $VID:$ |
|
446 | - */ |
|
447 | - protected function getGraphQLPriceTypes() |
|
448 | - { |
|
449 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
450 | - $query = <<<QUERY |
|
428 | + $data = [ |
|
429 | + 'operation_name' => 'GET_PRICES', |
|
430 | + 'variables' => [ |
|
431 | + 'where' => [ |
|
432 | + 'ticketIn' => $ticketIn, |
|
433 | + ], |
|
434 | + ], |
|
435 | + 'query' => $query, |
|
436 | + ]; |
|
437 | + |
|
438 | + $responseData = $this->makeGraphQLRequest($data); |
|
439 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * @return array|null |
|
445 | + * @since $VID:$ |
|
446 | + */ |
|
447 | + protected function getGraphQLPriceTypes() |
|
448 | + { |
|
449 | + $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
450 | + $query = <<<QUERY |
|
451 | 451 | query GET_PRICES { |
452 | 452 | {$field_key} { |
453 | 453 | nodes { |
@@ -467,280 +467,280 @@ discard block |
||
467 | 467 | } |
468 | 468 | } |
469 | 469 | QUERY; |
470 | - $data = [ |
|
471 | - 'operation_name' => 'GET_PRICES', |
|
472 | - 'query' => $query, |
|
473 | - ]; |
|
474 | - |
|
475 | - $responseData = $this->makeGraphQLRequest($data); |
|
476 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * @param array $data |
|
482 | - * @return array |
|
483 | - * @since $VID:$ |
|
484 | - */ |
|
485 | - protected function makeGraphQLRequest($data) |
|
486 | - { |
|
487 | - try { |
|
488 | - $response = graphql($data); |
|
489 | - if (!empty($response['data'])) { |
|
490 | - return $response['data']; |
|
491 | - } |
|
492 | - return null; |
|
493 | - } catch (\Exception $e) { |
|
494 | - // do something with the errors thrown |
|
495 | - return null; |
|
496 | - } |
|
497 | - } |
|
498 | - |
|
499 | - |
|
500 | - /** |
|
501 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
502 | - * @param array $args The inputArgs on the field |
|
503 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
504 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
505 | - * @return string |
|
506 | - * @throws EE_Error |
|
507 | - * @throws Exception |
|
508 | - * @throws InvalidArgumentException |
|
509 | - * @throws InvalidDataTypeException |
|
510 | - * @throws InvalidInterfaceException |
|
511 | - * @throws ReflectionException |
|
512 | - * @throws UserError |
|
513 | - * @throws UnexpectedEntityException |
|
514 | - * @since $VID:$ |
|
515 | - */ |
|
516 | - public static function getRelationalData($eventId) |
|
517 | - { |
|
518 | - |
|
519 | - $data = [ |
|
520 | - 'datetimes' => [], |
|
521 | - 'tickets' => [], |
|
522 | - 'prices' => [], |
|
523 | - ]; |
|
524 | - |
|
525 | - $eem_datetime = EEM_Datetime::instance(); |
|
526 | - $eem_ticket = EEM_Ticket::instance(); |
|
527 | - $eem_price = EEM_Price::instance(); |
|
528 | - $eem_price_type = EEM_Price_Type::instance(); |
|
529 | - |
|
530 | - // PROCESS DATETIMES |
|
531 | - $related_models = [ |
|
532 | - 'tickets' => $eem_ticket, |
|
533 | - ]; |
|
534 | - // Get the IDs of event datetimes. |
|
535 | - $datetimeIds = $eem_datetime->get_col([['EVT_ID' => $eventId]]); |
|
536 | - foreach ($datetimeIds as $datetimeId) { |
|
537 | - $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
538 | - foreach ($related_models as $key => $model) { |
|
539 | - // Get the IDs of related entities for the datetime ID. |
|
540 | - $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
541 | - if (! empty($Ids)) { |
|
542 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
543 | - } |
|
544 | - } |
|
545 | - } |
|
546 | - |
|
547 | - // PROCESS TICKETS |
|
548 | - $related_models = [ |
|
549 | - 'datetimes' => $eem_datetime, |
|
550 | - 'prices' => $eem_price, |
|
551 | - ]; |
|
552 | - // Get the IDs of all datetime tickets. |
|
553 | - $ticketIds = $eem_ticket->get_col([['Datetime.DTT_ID' => ['in', $datetimeIds]]]); |
|
554 | - foreach ($ticketIds as $ticketId) { |
|
555 | - $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
556 | - |
|
557 | - foreach ($related_models as $key => $model) { |
|
558 | - // Get the IDs of related entities for the ticket ID. |
|
559 | - $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
560 | - if (! empty($Ids)) { |
|
561 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
562 | - } |
|
563 | - } |
|
564 | - } |
|
565 | - |
|
566 | - // PROCESS PRICES |
|
567 | - $related_models = [ |
|
568 | - 'tickets' => $eem_ticket, |
|
569 | - 'priceTypes' => $eem_price_type, |
|
570 | - ]; |
|
571 | - // Get the IDs of all ticket prices. |
|
572 | - $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
573 | - foreach ($priceIds as $priceId) { |
|
574 | - $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
575 | - |
|
576 | - foreach ($related_models as $key => $model) { |
|
577 | - // Get the IDs of related entities for the price ID. |
|
578 | - $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
579 | - if (! empty($Ids)) { |
|
580 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
581 | - } |
|
582 | - } |
|
583 | - } |
|
584 | - |
|
585 | - return $data; |
|
586 | - } |
|
587 | - |
|
588 | - /** |
|
589 | - * Convert the DB ID into GID |
|
590 | - * |
|
591 | - * @param string $type |
|
592 | - * @param int|int[] $ID |
|
593 | - * @return mixed |
|
594 | - */ |
|
595 | - public static function convertToGlobalId($type, $ID) |
|
596 | - { |
|
597 | - if (is_array($ID)) { |
|
598 | - return array_map(function ($id) use ($type) { |
|
599 | - return self::convertToGlobalId($type, $id); |
|
600 | - }, $ID); |
|
601 | - } |
|
602 | - return Relay::toGlobalId($type, $ID); |
|
603 | - } |
|
604 | - |
|
605 | - |
|
606 | - /** |
|
607 | - * @param int $eventId |
|
608 | - * @return array |
|
609 | - * @throws EE_Error |
|
610 | - * @throws InvalidDataTypeException |
|
611 | - * @throws InvalidInterfaceException |
|
612 | - * @throws ModelConfigurationException |
|
613 | - * @throws RestPasswordIncorrectException |
|
614 | - * @throws RestPasswordRequiredException |
|
615 | - * @throws UnexpectedEntityException |
|
616 | - * @throws RestException |
|
617 | - * @throws InvalidArgumentException |
|
618 | - * @throws ReflectionException |
|
619 | - * @throws DomainException |
|
620 | - * @since $VID:$ |
|
621 | - */ |
|
622 | - protected function getAllEventData($eventId) |
|
623 | - { |
|
624 | - // these should ultimately be extracted out into their own classes (one per model) |
|
625 | - $event = $this->spoofer->getOneApiResult( |
|
626 | - $this->event_model, |
|
627 | - [['EVT_ID' => $eventId]] |
|
628 | - ); |
|
629 | - if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) { |
|
630 | - return []; |
|
631 | - } |
|
632 | - $eventDates = $this->getEventDates($eventId); |
|
633 | - if ((! is_array($eventDates) || empty($eventDates)) |
|
634 | - || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new') |
|
635 | - ) { |
|
636 | - $this->addDefaultEntities($eventId); |
|
637 | - $eventDates = $this->getEventDates($eventId); |
|
638 | - } |
|
639 | - |
|
640 | - $event = [$eventId => $event]; |
|
641 | - $relations = [ |
|
642 | - 'event' => [ |
|
643 | - $eventId => [ |
|
644 | - 'datetime' => [] |
|
645 | - ] |
|
646 | - ], |
|
647 | - 'datetime' => [], |
|
648 | - 'ticket' => [], |
|
649 | - 'price' => [], |
|
650 | - ]; |
|
651 | - |
|
652 | - $datetimes = []; |
|
653 | - $eventDateTickets = []; |
|
654 | - if (is_array($eventDates)) { |
|
655 | - foreach ($eventDates as $eventDate) { |
|
656 | - if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) { |
|
657 | - $DTT_ID = $eventDate['DTT_ID']; |
|
658 | - $datetimes[ $DTT_ID ] = $eventDate; |
|
659 | - $relations['event'][ $eventId ]['datetime'][] = $DTT_ID; |
|
660 | - $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults( |
|
661 | - $this->ticket_model, |
|
662 | - [[ |
|
663 | - 'Datetime.DTT_ID' => $DTT_ID, |
|
664 | - 'TKT_deleted' => ['IN', [true, false]] |
|
665 | - ]] |
|
666 | - ); |
|
667 | - } |
|
668 | - } |
|
669 | - } |
|
670 | - |
|
671 | - $prices = []; |
|
672 | - $tickets = []; |
|
673 | - if (is_array($eventDateTickets)) { |
|
674 | - foreach ($eventDateTickets as $DTT_ID => $dateTickets) { |
|
675 | - if (is_array($dateTickets)) { |
|
676 | - $relations['datetime'][ $DTT_ID ]['ticket'] = []; |
|
677 | - foreach ($dateTickets as $ticket) { |
|
678 | - if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) { |
|
679 | - $TKT_ID = $ticket['TKT_ID']; |
|
680 | - $tickets[ $TKT_ID ] = $ticket; |
|
681 | - $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID; |
|
682 | - $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults( |
|
683 | - $this->price_model, |
|
684 | - [['Ticket.TKT_ID' => $TKT_ID]] |
|
685 | - ); |
|
686 | - if (is_array($ticketPrices[ $TKT_ID ])) { |
|
687 | - $relations['ticket'][ $TKT_ID ]['price'] = []; |
|
688 | - foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) { |
|
689 | - $PRC_ID = $ticketPrice['PRC_ID']; |
|
690 | - $prices[ $PRC_ID ] = $ticketPrice; |
|
691 | - $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID; |
|
692 | - } |
|
693 | - } |
|
694 | - } |
|
695 | - } |
|
696 | - } |
|
697 | - } |
|
698 | - } |
|
699 | - $price_type_results = $this->spoofer->getApiResults( |
|
700 | - $this->price_type_model, |
|
701 | - [['PRT_deleted' => false]] |
|
702 | - ); |
|
703 | - $price_types = []; |
|
704 | - foreach ($price_type_results as $price_type) { |
|
705 | - $price_types[ $price_type['PRT_ID'] ] = $price_type; |
|
706 | - } |
|
707 | - $venue = $this->spoofer->getOneApiResult( |
|
708 | - $this->venue_model, |
|
709 | - [['Event.EVT_ID' => $eventId]] |
|
710 | - ); |
|
711 | - if (is_array($venue) && isset($venue['VNU_ID'])) { |
|
712 | - $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ]; |
|
713 | - $venue = [$venue['VNU_ID'] => $venue]; |
|
714 | - } |
|
715 | - |
|
716 | - $schemas = [ |
|
717 | - 'event' => $this->spoofer->getModelSchema('events'), |
|
718 | - 'datetime' => $this->spoofer->getModelSchema('datetimes'), |
|
719 | - 'ticket' => $this->spoofer->getModelSchema('tickets'), |
|
720 | - 'price' => $this->spoofer->getModelSchema('prices'), |
|
721 | - 'price_type' => $this->spoofer->getModelSchema('price_types'), |
|
722 | - 'venue' => $this->spoofer->getModelSchema('venues'), |
|
723 | - ]; |
|
724 | - |
|
725 | - $tktRegCount = []; |
|
726 | - foreach ($tickets as $ticket) { |
|
727 | - $tkt_instance = $this->ticket_model->get_one_by_ID($ticket['TKT_ID']); |
|
728 | - |
|
729 | - $tktRegCount[ $ticket['TKT_ID'] ] = $tkt_instance instanceof EE_Ticket ? |
|
730 | - $tkt_instance->count_registrations() |
|
731 | - : 0; |
|
732 | - } |
|
733 | - return [ |
|
734 | - 'eventId' => $eventId, |
|
735 | - 'event' => $event, |
|
736 | - 'datetime' => $datetimes, |
|
737 | - 'ticket' => $tickets, |
|
738 | - 'price' => $prices, |
|
739 | - 'price_type' => $price_types, |
|
740 | - 'venue' => $venue, |
|
741 | - 'schemas' => $schemas, |
|
742 | - 'relations' => $relations, |
|
743 | - 'tktRegCount' => $tktRegCount, |
|
744 | - ]; |
|
745 | - } |
|
470 | + $data = [ |
|
471 | + 'operation_name' => 'GET_PRICES', |
|
472 | + 'query' => $query, |
|
473 | + ]; |
|
474 | + |
|
475 | + $responseData = $this->makeGraphQLRequest($data); |
|
476 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * @param array $data |
|
482 | + * @return array |
|
483 | + * @since $VID:$ |
|
484 | + */ |
|
485 | + protected function makeGraphQLRequest($data) |
|
486 | + { |
|
487 | + try { |
|
488 | + $response = graphql($data); |
|
489 | + if (!empty($response['data'])) { |
|
490 | + return $response['data']; |
|
491 | + } |
|
492 | + return null; |
|
493 | + } catch (\Exception $e) { |
|
494 | + // do something with the errors thrown |
|
495 | + return null; |
|
496 | + } |
|
497 | + } |
|
498 | + |
|
499 | + |
|
500 | + /** |
|
501 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
502 | + * @param array $args The inputArgs on the field |
|
503 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
504 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
505 | + * @return string |
|
506 | + * @throws EE_Error |
|
507 | + * @throws Exception |
|
508 | + * @throws InvalidArgumentException |
|
509 | + * @throws InvalidDataTypeException |
|
510 | + * @throws InvalidInterfaceException |
|
511 | + * @throws ReflectionException |
|
512 | + * @throws UserError |
|
513 | + * @throws UnexpectedEntityException |
|
514 | + * @since $VID:$ |
|
515 | + */ |
|
516 | + public static function getRelationalData($eventId) |
|
517 | + { |
|
518 | + |
|
519 | + $data = [ |
|
520 | + 'datetimes' => [], |
|
521 | + 'tickets' => [], |
|
522 | + 'prices' => [], |
|
523 | + ]; |
|
524 | + |
|
525 | + $eem_datetime = EEM_Datetime::instance(); |
|
526 | + $eem_ticket = EEM_Ticket::instance(); |
|
527 | + $eem_price = EEM_Price::instance(); |
|
528 | + $eem_price_type = EEM_Price_Type::instance(); |
|
529 | + |
|
530 | + // PROCESS DATETIMES |
|
531 | + $related_models = [ |
|
532 | + 'tickets' => $eem_ticket, |
|
533 | + ]; |
|
534 | + // Get the IDs of event datetimes. |
|
535 | + $datetimeIds = $eem_datetime->get_col([['EVT_ID' => $eventId]]); |
|
536 | + foreach ($datetimeIds as $datetimeId) { |
|
537 | + $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
538 | + foreach ($related_models as $key => $model) { |
|
539 | + // Get the IDs of related entities for the datetime ID. |
|
540 | + $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
541 | + if (! empty($Ids)) { |
|
542 | + $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
543 | + } |
|
544 | + } |
|
545 | + } |
|
546 | + |
|
547 | + // PROCESS TICKETS |
|
548 | + $related_models = [ |
|
549 | + 'datetimes' => $eem_datetime, |
|
550 | + 'prices' => $eem_price, |
|
551 | + ]; |
|
552 | + // Get the IDs of all datetime tickets. |
|
553 | + $ticketIds = $eem_ticket->get_col([['Datetime.DTT_ID' => ['in', $datetimeIds]]]); |
|
554 | + foreach ($ticketIds as $ticketId) { |
|
555 | + $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
556 | + |
|
557 | + foreach ($related_models as $key => $model) { |
|
558 | + // Get the IDs of related entities for the ticket ID. |
|
559 | + $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
560 | + if (! empty($Ids)) { |
|
561 | + $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
562 | + } |
|
563 | + } |
|
564 | + } |
|
565 | + |
|
566 | + // PROCESS PRICES |
|
567 | + $related_models = [ |
|
568 | + 'tickets' => $eem_ticket, |
|
569 | + 'priceTypes' => $eem_price_type, |
|
570 | + ]; |
|
571 | + // Get the IDs of all ticket prices. |
|
572 | + $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
573 | + foreach ($priceIds as $priceId) { |
|
574 | + $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
575 | + |
|
576 | + foreach ($related_models as $key => $model) { |
|
577 | + // Get the IDs of related entities for the price ID. |
|
578 | + $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
579 | + if (! empty($Ids)) { |
|
580 | + $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
581 | + } |
|
582 | + } |
|
583 | + } |
|
584 | + |
|
585 | + return $data; |
|
586 | + } |
|
587 | + |
|
588 | + /** |
|
589 | + * Convert the DB ID into GID |
|
590 | + * |
|
591 | + * @param string $type |
|
592 | + * @param int|int[] $ID |
|
593 | + * @return mixed |
|
594 | + */ |
|
595 | + public static function convertToGlobalId($type, $ID) |
|
596 | + { |
|
597 | + if (is_array($ID)) { |
|
598 | + return array_map(function ($id) use ($type) { |
|
599 | + return self::convertToGlobalId($type, $id); |
|
600 | + }, $ID); |
|
601 | + } |
|
602 | + return Relay::toGlobalId($type, $ID); |
|
603 | + } |
|
604 | + |
|
605 | + |
|
606 | + /** |
|
607 | + * @param int $eventId |
|
608 | + * @return array |
|
609 | + * @throws EE_Error |
|
610 | + * @throws InvalidDataTypeException |
|
611 | + * @throws InvalidInterfaceException |
|
612 | + * @throws ModelConfigurationException |
|
613 | + * @throws RestPasswordIncorrectException |
|
614 | + * @throws RestPasswordRequiredException |
|
615 | + * @throws UnexpectedEntityException |
|
616 | + * @throws RestException |
|
617 | + * @throws InvalidArgumentException |
|
618 | + * @throws ReflectionException |
|
619 | + * @throws DomainException |
|
620 | + * @since $VID:$ |
|
621 | + */ |
|
622 | + protected function getAllEventData($eventId) |
|
623 | + { |
|
624 | + // these should ultimately be extracted out into their own classes (one per model) |
|
625 | + $event = $this->spoofer->getOneApiResult( |
|
626 | + $this->event_model, |
|
627 | + [['EVT_ID' => $eventId]] |
|
628 | + ); |
|
629 | + if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) { |
|
630 | + return []; |
|
631 | + } |
|
632 | + $eventDates = $this->getEventDates($eventId); |
|
633 | + if ((! is_array($eventDates) || empty($eventDates)) |
|
634 | + || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new') |
|
635 | + ) { |
|
636 | + $this->addDefaultEntities($eventId); |
|
637 | + $eventDates = $this->getEventDates($eventId); |
|
638 | + } |
|
639 | + |
|
640 | + $event = [$eventId => $event]; |
|
641 | + $relations = [ |
|
642 | + 'event' => [ |
|
643 | + $eventId => [ |
|
644 | + 'datetime' => [] |
|
645 | + ] |
|
646 | + ], |
|
647 | + 'datetime' => [], |
|
648 | + 'ticket' => [], |
|
649 | + 'price' => [], |
|
650 | + ]; |
|
651 | + |
|
652 | + $datetimes = []; |
|
653 | + $eventDateTickets = []; |
|
654 | + if (is_array($eventDates)) { |
|
655 | + foreach ($eventDates as $eventDate) { |
|
656 | + if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) { |
|
657 | + $DTT_ID = $eventDate['DTT_ID']; |
|
658 | + $datetimes[ $DTT_ID ] = $eventDate; |
|
659 | + $relations['event'][ $eventId ]['datetime'][] = $DTT_ID; |
|
660 | + $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults( |
|
661 | + $this->ticket_model, |
|
662 | + [[ |
|
663 | + 'Datetime.DTT_ID' => $DTT_ID, |
|
664 | + 'TKT_deleted' => ['IN', [true, false]] |
|
665 | + ]] |
|
666 | + ); |
|
667 | + } |
|
668 | + } |
|
669 | + } |
|
670 | + |
|
671 | + $prices = []; |
|
672 | + $tickets = []; |
|
673 | + if (is_array($eventDateTickets)) { |
|
674 | + foreach ($eventDateTickets as $DTT_ID => $dateTickets) { |
|
675 | + if (is_array($dateTickets)) { |
|
676 | + $relations['datetime'][ $DTT_ID ]['ticket'] = []; |
|
677 | + foreach ($dateTickets as $ticket) { |
|
678 | + if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) { |
|
679 | + $TKT_ID = $ticket['TKT_ID']; |
|
680 | + $tickets[ $TKT_ID ] = $ticket; |
|
681 | + $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID; |
|
682 | + $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults( |
|
683 | + $this->price_model, |
|
684 | + [['Ticket.TKT_ID' => $TKT_ID]] |
|
685 | + ); |
|
686 | + if (is_array($ticketPrices[ $TKT_ID ])) { |
|
687 | + $relations['ticket'][ $TKT_ID ]['price'] = []; |
|
688 | + foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) { |
|
689 | + $PRC_ID = $ticketPrice['PRC_ID']; |
|
690 | + $prices[ $PRC_ID ] = $ticketPrice; |
|
691 | + $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID; |
|
692 | + } |
|
693 | + } |
|
694 | + } |
|
695 | + } |
|
696 | + } |
|
697 | + } |
|
698 | + } |
|
699 | + $price_type_results = $this->spoofer->getApiResults( |
|
700 | + $this->price_type_model, |
|
701 | + [['PRT_deleted' => false]] |
|
702 | + ); |
|
703 | + $price_types = []; |
|
704 | + foreach ($price_type_results as $price_type) { |
|
705 | + $price_types[ $price_type['PRT_ID'] ] = $price_type; |
|
706 | + } |
|
707 | + $venue = $this->spoofer->getOneApiResult( |
|
708 | + $this->venue_model, |
|
709 | + [['Event.EVT_ID' => $eventId]] |
|
710 | + ); |
|
711 | + if (is_array($venue) && isset($venue['VNU_ID'])) { |
|
712 | + $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ]; |
|
713 | + $venue = [$venue['VNU_ID'] => $venue]; |
|
714 | + } |
|
715 | + |
|
716 | + $schemas = [ |
|
717 | + 'event' => $this->spoofer->getModelSchema('events'), |
|
718 | + 'datetime' => $this->spoofer->getModelSchema('datetimes'), |
|
719 | + 'ticket' => $this->spoofer->getModelSchema('tickets'), |
|
720 | + 'price' => $this->spoofer->getModelSchema('prices'), |
|
721 | + 'price_type' => $this->spoofer->getModelSchema('price_types'), |
|
722 | + 'venue' => $this->spoofer->getModelSchema('venues'), |
|
723 | + ]; |
|
724 | + |
|
725 | + $tktRegCount = []; |
|
726 | + foreach ($tickets as $ticket) { |
|
727 | + $tkt_instance = $this->ticket_model->get_one_by_ID($ticket['TKT_ID']); |
|
728 | + |
|
729 | + $tktRegCount[ $ticket['TKT_ID'] ] = $tkt_instance instanceof EE_Ticket ? |
|
730 | + $tkt_instance->count_registrations() |
|
731 | + : 0; |
|
732 | + } |
|
733 | + return [ |
|
734 | + 'eventId' => $eventId, |
|
735 | + 'event' => $event, |
|
736 | + 'datetime' => $datetimes, |
|
737 | + 'ticket' => $tickets, |
|
738 | + 'price' => $prices, |
|
739 | + 'price_type' => $price_types, |
|
740 | + 'venue' => $venue, |
|
741 | + 'schemas' => $schemas, |
|
742 | + 'relations' => $relations, |
|
743 | + 'tktRegCount' => $tktRegCount, |
|
744 | + ]; |
|
745 | + } |
|
746 | 746 | } |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | { |
146 | 146 | if ($this->admin_config->useAdvancedEditor()) { |
147 | 147 | $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
148 | - if (! $eventId) { |
|
148 | + if ( ! $eventId) { |
|
149 | 149 | global $post; |
150 | 150 | $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
151 | 151 | $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
152 | 152 | ? $post->ID |
153 | 153 | : $eventId; |
154 | 154 | } |
155 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
155 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : ''; |
|
156 | 156 | $graphqlEndpoint = esc_url($graphqlEndpoint); |
157 | 157 | if ($eventId) { |
158 | 158 | $data = $this->getAllEventData($eventId); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $GQLdata = wp_json_encode($GQLdata); |
162 | 162 | add_action( |
163 | 163 | 'admin_footer', |
164 | - static function () use ($data, $graphqlEndpoint) { |
|
164 | + static function() use ($data, $graphqlEndpoint) { |
|
165 | 165 | wp_add_inline_script( |
166 | 166 | EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
167 | 167 | " |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ); |
175 | 175 | add_action( |
176 | 176 | 'admin_footer', |
177 | - static function () use ($data, $GQLdata, $graphqlEndpoint) { |
|
177 | + static function() use ($data, $GQLdata, $graphqlEndpoint) { |
|
178 | 178 | wp_add_inline_script( |
179 | 179 | EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
180 | 180 | " |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | { |
268 | 268 | $datetimes = $this->getGraphQLDatetimes($eventId); |
269 | 269 | |
270 | - if (! empty($datetimes['nodes'])) { |
|
270 | + if ( ! empty($datetimes['nodes'])) { |
|
271 | 271 | $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
272 | 272 | |
273 | - if (! empty($datetimeIn)) { |
|
273 | + if ( ! empty($datetimeIn)) { |
|
274 | 274 | $tickets = $this->getGraphQLTickets($datetimeIn); |
275 | 275 | } |
276 | 276 | } |
277 | 277 | |
278 | - if (! empty($tickets['nodes'])) { |
|
278 | + if ( ! empty($tickets['nodes'])) { |
|
279 | 279 | $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
280 | 280 | |
281 | - if (! empty($ticketIn)) { |
|
281 | + if ( ! empty($ticketIn)) { |
|
282 | 282 | $prices = $this->getGraphQLPrices($ticketIn); |
283 | 283 | } |
284 | 284 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | */ |
299 | 299 | protected function getGraphQLDatetimes($eventId) |
300 | 300 | { |
301 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
301 | + $field_key = lcfirst($this->namespace).'Datetimes'; |
|
302 | 302 | $query = <<<QUERY |
303 | 303 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
304 | 304 | {$field_key}(where: \$where) { |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | ]; |
338 | 338 | |
339 | 339 | $responseData = $this->makeGraphQLRequest($data); |
340 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
340 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | */ |
349 | 349 | protected function getGraphQLTickets(array $datetimeIn) |
350 | 350 | { |
351 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
351 | + $field_key = lcfirst($this->namespace).'Tickets'; |
|
352 | 352 | $query = <<<QUERY |
353 | 353 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
354 | 354 | {$field_key}(where: \$where) { |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | ]; |
390 | 390 | |
391 | 391 | $responseData = $this->makeGraphQLRequest($data); |
392 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
392 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | */ |
401 | 401 | protected function getGraphQLPrices(array $ticketIn) |
402 | 402 | { |
403 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
403 | + $field_key = lcfirst($this->namespace).'Prices'; |
|
404 | 404 | $query = <<<QUERY |
405 | 405 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
406 | 406 | {$field_key}(where: \$where) { |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | ]; |
437 | 437 | |
438 | 438 | $responseData = $this->makeGraphQLRequest($data); |
439 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
439 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | */ |
447 | 447 | protected function getGraphQLPriceTypes() |
448 | 448 | { |
449 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
449 | + $field_key = lcfirst($this->namespace).'PriceTypes'; |
|
450 | 450 | $query = <<<QUERY |
451 | 451 | query GET_PRICES { |
452 | 452 | {$field_key} { |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | ]; |
474 | 474 | |
475 | 475 | $responseData = $this->makeGraphQLRequest($data); |
476 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
476 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | { |
487 | 487 | try { |
488 | 488 | $response = graphql($data); |
489 | - if (!empty($response['data'])) { |
|
489 | + if ( ! empty($response['data'])) { |
|
490 | 490 | return $response['data']; |
491 | 491 | } |
492 | 492 | return null; |
@@ -538,8 +538,8 @@ discard block |
||
538 | 538 | foreach ($related_models as $key => $model) { |
539 | 539 | // Get the IDs of related entities for the datetime ID. |
540 | 540 | $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
541 | - if (! empty($Ids)) { |
|
542 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
541 | + if ( ! empty($Ids)) { |
|
542 | + $data['datetimes'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | } |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | foreach ($related_models as $key => $model) { |
558 | 558 | // Get the IDs of related entities for the ticket ID. |
559 | 559 | $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
560 | - if (! empty($Ids)) { |
|
561 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
560 | + if ( ! empty($Ids)) { |
|
561 | + $data['tickets'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
562 | 562 | } |
563 | 563 | } |
564 | 564 | } |
@@ -576,8 +576,8 @@ discard block |
||
576 | 576 | foreach ($related_models as $key => $model) { |
577 | 577 | // Get the IDs of related entities for the price ID. |
578 | 578 | $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
579 | - if (! empty($Ids)) { |
|
580 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
579 | + if ( ! empty($Ids)) { |
|
580 | + $data['prices'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
581 | 581 | } |
582 | 582 | } |
583 | 583 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | public static function convertToGlobalId($type, $ID) |
596 | 596 | { |
597 | 597 | if (is_array($ID)) { |
598 | - return array_map(function ($id) use ($type) { |
|
598 | + return array_map(function($id) use ($type) { |
|
599 | 599 | return self::convertToGlobalId($type, $id); |
600 | 600 | }, $ID); |
601 | 601 | } |
@@ -626,11 +626,11 @@ discard block |
||
626 | 626 | $this->event_model, |
627 | 627 | [['EVT_ID' => $eventId]] |
628 | 628 | ); |
629 | - if (! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) { |
|
629 | + if ( ! (is_array($event) && isset($event['EVT_ID']) && $event['EVT_ID'] === $eventId)) { |
|
630 | 630 | return []; |
631 | 631 | } |
632 | 632 | $eventDates = $this->getEventDates($eventId); |
633 | - if ((! is_array($eventDates) || empty($eventDates)) |
|
633 | + if (( ! is_array($eventDates) || empty($eventDates)) |
|
634 | 634 | || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new') |
635 | 635 | ) { |
636 | 636 | $this->addDefaultEntities($eventId); |
@@ -655,9 +655,9 @@ discard block |
||
655 | 655 | foreach ($eventDates as $eventDate) { |
656 | 656 | if (isset($eventDate['DTT_ID']) && $eventDate['DTT_ID']) { |
657 | 657 | $DTT_ID = $eventDate['DTT_ID']; |
658 | - $datetimes[ $DTT_ID ] = $eventDate; |
|
659 | - $relations['event'][ $eventId ]['datetime'][] = $DTT_ID; |
|
660 | - $eventDateTickets[ $DTT_ID ] = $this->spoofer->getApiResults( |
|
658 | + $datetimes[$DTT_ID] = $eventDate; |
|
659 | + $relations['event'][$eventId]['datetime'][] = $DTT_ID; |
|
660 | + $eventDateTickets[$DTT_ID] = $this->spoofer->getApiResults( |
|
661 | 661 | $this->ticket_model, |
662 | 662 | [[ |
663 | 663 | 'Datetime.DTT_ID' => $DTT_ID, |
@@ -673,22 +673,22 @@ discard block |
||
673 | 673 | if (is_array($eventDateTickets)) { |
674 | 674 | foreach ($eventDateTickets as $DTT_ID => $dateTickets) { |
675 | 675 | if (is_array($dateTickets)) { |
676 | - $relations['datetime'][ $DTT_ID ]['ticket'] = []; |
|
676 | + $relations['datetime'][$DTT_ID]['ticket'] = []; |
|
677 | 677 | foreach ($dateTickets as $ticket) { |
678 | 678 | if (isset($ticket['TKT_ID']) && $ticket['TKT_ID']) { |
679 | 679 | $TKT_ID = $ticket['TKT_ID']; |
680 | - $tickets[ $TKT_ID ] = $ticket; |
|
681 | - $relations['datetime'][ $DTT_ID ]['ticket'][] = $TKT_ID; |
|
682 | - $ticketPrices[ $TKT_ID ] = $this->spoofer->getApiResults( |
|
680 | + $tickets[$TKT_ID] = $ticket; |
|
681 | + $relations['datetime'][$DTT_ID]['ticket'][] = $TKT_ID; |
|
682 | + $ticketPrices[$TKT_ID] = $this->spoofer->getApiResults( |
|
683 | 683 | $this->price_model, |
684 | 684 | [['Ticket.TKT_ID' => $TKT_ID]] |
685 | 685 | ); |
686 | - if (is_array($ticketPrices[ $TKT_ID ])) { |
|
687 | - $relations['ticket'][ $TKT_ID ]['price'] = []; |
|
688 | - foreach ($ticketPrices[ $TKT_ID ] as $ticketPrice) { |
|
686 | + if (is_array($ticketPrices[$TKT_ID])) { |
|
687 | + $relations['ticket'][$TKT_ID]['price'] = []; |
|
688 | + foreach ($ticketPrices[$TKT_ID] as $ticketPrice) { |
|
689 | 689 | $PRC_ID = $ticketPrice['PRC_ID']; |
690 | - $prices[ $PRC_ID ] = $ticketPrice; |
|
691 | - $relations['ticket'][ $TKT_ID ]['price'][] = $PRC_ID; |
|
690 | + $prices[$PRC_ID] = $ticketPrice; |
|
691 | + $relations['ticket'][$TKT_ID]['price'][] = $PRC_ID; |
|
692 | 692 | } |
693 | 693 | } |
694 | 694 | } |
@@ -702,14 +702,14 @@ discard block |
||
702 | 702 | ); |
703 | 703 | $price_types = []; |
704 | 704 | foreach ($price_type_results as $price_type) { |
705 | - $price_types[ $price_type['PRT_ID'] ] = $price_type; |
|
705 | + $price_types[$price_type['PRT_ID']] = $price_type; |
|
706 | 706 | } |
707 | 707 | $venue = $this->spoofer->getOneApiResult( |
708 | 708 | $this->venue_model, |
709 | 709 | [['Event.EVT_ID' => $eventId]] |
710 | 710 | ); |
711 | 711 | if (is_array($venue) && isset($venue['VNU_ID'])) { |
712 | - $relations['event'][ $eventId ]['venue'] = [ $venue['VNU_ID'] ]; |
|
712 | + $relations['event'][$eventId]['venue'] = [$venue['VNU_ID']]; |
|
713 | 713 | $venue = [$venue['VNU_ID'] => $venue]; |
714 | 714 | } |
715 | 715 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | foreach ($tickets as $ticket) { |
727 | 727 | $tkt_instance = $this->ticket_model->get_one_by_ID($ticket['TKT_ID']); |
728 | 728 | |
729 | - $tktRegCount[ $ticket['TKT_ID'] ] = $tkt_instance instanceof EE_Ticket ? |
|
729 | + $tktRegCount[$ticket['TKT_ID']] = $tkt_instance instanceof EE_Ticket ? |
|
730 | 730 | $tkt_instance->count_registrations() |
731 | 731 | : 0; |
732 | 732 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | class DatetimesConnectionOrderbyEnum extends EnumBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * DatetimesConnectionOrderbyEnum constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
24 | - $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
18 | + /** |
|
19 | + * DatetimesConnectionOrderbyEnum constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
24 | + $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - * @since $VID:$ |
|
32 | - */ |
|
33 | - protected function getValues() |
|
34 | - { |
|
35 | - return [ |
|
36 | - 'NAME' => [ |
|
37 | - 'value' => 'DTT_name', |
|
38 | - 'description' => esc_html__('Order by name', 'event_espresso'), |
|
39 | - ], |
|
40 | - 'START_DATE' => [ |
|
41 | - 'value' => 'DTT_EVT_start', |
|
42 | - 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
43 | - ], |
|
44 | - ]; |
|
45 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + * @since $VID:$ |
|
32 | + */ |
|
33 | + protected function getValues() |
|
34 | + { |
|
35 | + return [ |
|
36 | + 'NAME' => [ |
|
37 | + 'value' => 'DTT_name', |
|
38 | + 'description' => esc_html__('Order by name', 'event_espresso'), |
|
39 | + ], |
|
40 | + 'START_DATE' => [ |
|
41 | + 'value' => 'DTT_EVT_start', |
|
42 | + 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
43 | + ], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyEnum'); |
|
23 | + $this->setName($this->namespace.'DatetimesConnectionOrderbyEnum'); |
|
24 | 24 | $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
25 | 25 | parent::__construct(); |
26 | 26 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | class TicketsConnectionOrderbyEnum extends EnumBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * TicketsConnectionOrderbyEnum constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
24 | - $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
18 | + /** |
|
19 | + * TicketsConnectionOrderbyEnum constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
24 | + $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - * @since $VID:$ |
|
32 | - */ |
|
33 | - protected function getValues() |
|
34 | - { |
|
35 | - return [ |
|
36 | - 'NAME' => [ |
|
37 | - 'value' => 'TKT_name', |
|
38 | - 'description' => esc_html__('Order by name', 'event_espresso'), |
|
39 | - ], |
|
40 | - 'START_DATE' => [ |
|
41 | - 'value' => 'TKT_start_date', |
|
42 | - 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
43 | - ], |
|
44 | - ]; |
|
45 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + * @since $VID:$ |
|
32 | + */ |
|
33 | + protected function getValues() |
|
34 | + { |
|
35 | + return [ |
|
36 | + 'NAME' => [ |
|
37 | + 'value' => 'TKT_name', |
|
38 | + 'description' => esc_html__('Order by name', 'event_espresso'), |
|
39 | + ], |
|
40 | + 'START_DATE' => [ |
|
41 | + 'value' => 'TKT_start_date', |
|
42 | + 'description' => esc_html__('Order by start date', 'event_espresso'), |
|
43 | + ], |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyEnum'); |
|
23 | + $this->setName($this->namespace.'TicketsConnectionOrderbyEnum'); |
|
24 | 24 | $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
25 | 25 | parent::__construct(); |
26 | 26 | } |
@@ -16,36 +16,36 @@ |
||
16 | 16 | class PriceBaseTypeEnum extends EnumBase |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * PriceBaseTypeEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
25 | - $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * PriceBaseTypeEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
25 | + $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - protected function getValues() |
|
35 | - { |
|
36 | - return [ |
|
37 | - 'BASE_PRICE' => [ |
|
38 | - 'value' => EEM_Price_Type::base_type_base_price, |
|
39 | - ], |
|
40 | - 'DISCOUNT' => [ |
|
41 | - 'value' => EEM_Price_Type::base_type_discount, |
|
42 | - ], |
|
43 | - 'SURCHARGE' => [ |
|
44 | - 'value' => EEM_Price_Type::base_type_surcharge, |
|
45 | - ], |
|
46 | - 'TAX' => [ |
|
47 | - 'value' => EEM_Price_Type::base_type_tax, |
|
48 | - ], |
|
49 | - ]; |
|
50 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + protected function getValues() |
|
35 | + { |
|
36 | + return [ |
|
37 | + 'BASE_PRICE' => [ |
|
38 | + 'value' => EEM_Price_Type::base_type_base_price, |
|
39 | + ], |
|
40 | + 'DISCOUNT' => [ |
|
41 | + 'value' => EEM_Price_Type::base_type_discount, |
|
42 | + ], |
|
43 | + 'SURCHARGE' => [ |
|
44 | + 'value' => EEM_Price_Type::base_type_surcharge, |
|
45 | + ], |
|
46 | + 'TAX' => [ |
|
47 | + 'value' => EEM_Price_Type::base_type_tax, |
|
48 | + ], |
|
49 | + ]; |
|
50 | + } |
|
51 | 51 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->setName($this->namespace . 'PriceBaseTypeEnum'); |
|
24 | + $this->setName($this->namespace.'PriceBaseTypeEnum'); |
|
25 | 25 | $this->setDescription(esc_html__('Price Base type ID', 'event_espresso')); |
26 | 26 | parent::__construct(); |
27 | 27 | } |
@@ -19,32 +19,32 @@ |
||
19 | 19 | class DatetimesConnectionOrderbyInput extends InputBase |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * DatetimesConnectionOrderbyInput constructor. |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
28 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
29 | - parent::__construct(); |
|
30 | - } |
|
22 | + /** |
|
23 | + * DatetimesConnectionOrderbyInput constructor. |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
28 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return GraphQLFieldInterface[] |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - protected function getFields() |
|
38 | - { |
|
39 | - return [ |
|
40 | - new GraphQLField( |
|
41 | - 'field', |
|
42 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
43 | - ), |
|
44 | - new GraphQLField( |
|
45 | - 'order', |
|
46 | - 'OrderEnum' |
|
47 | - ), |
|
48 | - ]; |
|
49 | - } |
|
33 | + /** |
|
34 | + * @return GraphQLFieldInterface[] |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + protected function getFields() |
|
38 | + { |
|
39 | + return [ |
|
40 | + new GraphQLField( |
|
41 | + 'field', |
|
42 | + ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
43 | + ), |
|
44 | + new GraphQLField( |
|
45 | + 'order', |
|
46 | + 'OrderEnum' |
|
47 | + ), |
|
48 | + ]; |
|
49 | + } |
|
50 | 50 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() |
26 | 26 | { |
27 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
27 | + $this->setName($this->namespace.'DatetimesConnectionOrderbyInput'); |
|
28 | 28 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
29 | 29 | parent::__construct(); |
30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | return [ |
40 | 40 | new GraphQLField( |
41 | 41 | 'field', |
42 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
42 | + ['non_null' => $this->namespace.'DatetimesConnectionOrderbyEnum'] |
|
43 | 43 | ), |
44 | 44 | new GraphQLField( |
45 | 45 | 'order', |
@@ -19,32 +19,32 @@ |
||
19 | 19 | class TicketsConnectionOrderbyInput extends InputBase |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * TicketsConnectionOrderbyInput constructor. |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
28 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
29 | - parent::__construct(); |
|
30 | - } |
|
22 | + /** |
|
23 | + * TicketsConnectionOrderbyInput constructor. |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
28 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
29 | + parent::__construct(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return GraphQLFieldInterface[] |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - protected function getFields() |
|
38 | - { |
|
39 | - return [ |
|
40 | - new GraphQLField( |
|
41 | - 'field', |
|
42 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
43 | - ), |
|
44 | - new GraphQLField( |
|
45 | - 'order', |
|
46 | - 'OrderEnum' |
|
47 | - ), |
|
48 | - ]; |
|
49 | - } |
|
33 | + /** |
|
34 | + * @return GraphQLFieldInterface[] |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + protected function getFields() |
|
38 | + { |
|
39 | + return [ |
|
40 | + new GraphQLField( |
|
41 | + 'field', |
|
42 | + ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
43 | + ), |
|
44 | + new GraphQLField( |
|
45 | + 'order', |
|
46 | + 'OrderEnum' |
|
47 | + ), |
|
48 | + ]; |
|
49 | + } |
|
50 | 50 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function __construct() |
26 | 26 | { |
27 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
27 | + $this->setName($this->namespace.'TicketsConnectionOrderbyInput'); |
|
28 | 28 | $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
29 | 29 | parent::__construct(); |
30 | 30 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | return [ |
40 | 40 | new GraphQLField( |
41 | 41 | 'field', |
42 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
42 | + ['non_null' => $this->namespace.'TicketsConnectionOrderbyEnum'] |
|
43 | 43 | ), |
44 | 44 | new GraphQLField( |
45 | 45 | 'order', |
@@ -19,46 +19,46 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * PriceConnection constructor. |
|
24 | - * |
|
25 | - * @param EEM_Price $model |
|
26 | - */ |
|
27 | - public function __construct(EEM_Price $model) |
|
28 | - { |
|
29 | - $this->model = $model; |
|
30 | - } |
|
22 | + /** |
|
23 | + * PriceConnection constructor. |
|
24 | + * |
|
25 | + * @param EEM_Price $model |
|
26 | + */ |
|
27 | + public function __construct(EEM_Price $model) |
|
28 | + { |
|
29 | + $this->model = $model; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function config() |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => 'RootQuery', |
|
41 | - 'toType' => $this->namespace . 'Price', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Prices', |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryPricesConnection", |
|
44 | - 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - 'resolveNode' => [$this, 'resolveNode'] |
|
47 | - ]; |
|
48 | - } |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function config() |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'Price', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace) . 'Prices', |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryPricesConnection", |
|
44 | + 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + 'resolveNode' => [$this, 'resolveNode'] |
|
47 | + ]; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @param $entity |
|
53 | - * @param $args |
|
54 | - * @param $context |
|
55 | - * @param $info |
|
56 | - * @return PriceConnectionResolver |
|
57 | - * @throws Exception |
|
58 | - * @since $VID:$ |
|
59 | - */ |
|
60 | - public function getConnectionResolver($entity, $args, $context, $info) |
|
61 | - { |
|
62 | - return new PriceConnectionResolver($entity, $args, $context, $info); |
|
63 | - } |
|
51 | + /** |
|
52 | + * @param $entity |
|
53 | + * @param $args |
|
54 | + * @param $context |
|
55 | + * @param $info |
|
56 | + * @return PriceConnectionResolver |
|
57 | + * @throws Exception |
|
58 | + * @since $VID:$ |
|
59 | + */ |
|
60 | + public function getConnectionResolver($entity, $args, $context, $info) |
|
61 | + { |
|
62 | + return new PriceConnectionResolver($entity, $args, $context, $info); |
|
63 | + } |
|
64 | 64 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | return [ |
40 | 40 | 'fromType' => 'RootQuery', |
41 | - 'toType' => $this->namespace . 'Price', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Prices', |
|
41 | + 'toType' => $this->namespace.'Price', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace).'Prices', |
|
43 | 43 | 'connectionTypeName' => "{$this->namespace}RootQueryPricesConnection", |
44 | 44 | 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
45 | 45 | 'resolve' => [$this, 'resolveConnection'], |
@@ -20,99 +20,99 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * DatetimeConnection constructor. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - */ |
|
28 | - public function __construct(EEM_Ticket $model) |
|
29 | - { |
|
30 | - $this->model = $model; |
|
31 | - } |
|
23 | + /** |
|
24 | + * DatetimeConnection constructor. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + */ |
|
28 | + public function __construct(EEM_Ticket $model) |
|
29 | + { |
|
30 | + $this->model = $model; |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @return array |
|
36 | - * @since $VID:$ |
|
37 | - */ |
|
38 | - public function config() |
|
39 | - { |
|
40 | - return [ |
|
41 | - 'fromType' => $this->namespace . 'Datetime', |
|
42 | - 'toType' => $this->namespace . 'Ticket', |
|
43 | - 'fromFieldName' => 'tickets', |
|
44 | - 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
45 | - 'connectionArgs' => self::get_connection_args(), |
|
46 | - 'resolve' => [$this, 'resolveConnection'], |
|
47 | - 'resolveNode' => [$this, 'resolveNode'] |
|
48 | - ]; |
|
49 | - } |
|
34 | + /** |
|
35 | + * @return array |
|
36 | + * @since $VID:$ |
|
37 | + */ |
|
38 | + public function config() |
|
39 | + { |
|
40 | + return [ |
|
41 | + 'fromType' => $this->namespace . 'Datetime', |
|
42 | + 'toType' => $this->namespace . 'Ticket', |
|
43 | + 'fromFieldName' => 'tickets', |
|
44 | + 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
|
45 | + 'connectionArgs' => self::get_connection_args(), |
|
46 | + 'resolve' => [$this, 'resolveConnection'], |
|
47 | + 'resolveNode' => [$this, 'resolveNode'] |
|
48 | + ]; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @param $entity |
|
54 | - * @param $args |
|
55 | - * @param $context |
|
56 | - * @param $info |
|
57 | - * @return array |
|
58 | - * @throws Exception |
|
59 | - * @since $VID:$ |
|
60 | - */ |
|
61 | - public function resolveConnection($entity, $args, $context, $info) |
|
62 | - { |
|
63 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
64 | - return $resolver->get_connection(); |
|
65 | - } |
|
52 | + /** |
|
53 | + * @param $entity |
|
54 | + * @param $args |
|
55 | + * @param $context |
|
56 | + * @param $info |
|
57 | + * @return array |
|
58 | + * @throws Exception |
|
59 | + * @since $VID:$ |
|
60 | + */ |
|
61 | + public function resolveConnection($entity, $args, $context, $info) |
|
62 | + { |
|
63 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
64 | + return $resolver->get_connection(); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @param $id |
|
70 | - * @param $args |
|
71 | - * @param $context |
|
72 | - * @param $info |
|
73 | - * @return EE_Base_Class |
|
74 | - * @since $VID:$ |
|
75 | - */ |
|
76 | - public function resolveNode($id, $args, $context, $info) |
|
77 | - { |
|
78 | - return $this->model->get_one_by_ID($id); |
|
79 | - } |
|
68 | + /** |
|
69 | + * @param $id |
|
70 | + * @param $args |
|
71 | + * @param $context |
|
72 | + * @param $info |
|
73 | + * @return EE_Base_Class |
|
74 | + * @since $VID:$ |
|
75 | + */ |
|
76 | + public function resolveNode($id, $args, $context, $info) |
|
77 | + { |
|
78 | + return $this->model->get_one_by_ID($id); |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Given an optional array of args, this returns the args to be used in the connection |
|
83 | - * |
|
84 | - * @access public |
|
85 | - * @param array $args The args to modify the defaults |
|
86 | - * |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
90 | - public static function get_connection_args($args = []) |
|
91 | - { |
|
92 | - return array_merge( |
|
93 | - [ |
|
94 | - 'orderby' => [ |
|
95 | - 'type' => ['list_of' => 'TicketsConnectionOrderbyInput'], |
|
96 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
97 | - ], |
|
98 | - 'datetime' => [ |
|
99 | - 'type' => 'ID', |
|
100 | - 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
101 | - ], |
|
102 | - 'datetimeIn' => [ |
|
103 | - 'type' => ['list_of' => 'ID'], |
|
104 | - 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
105 | - ], |
|
106 | - 'datetimeId' => [ |
|
107 | - 'type' => 'Int', |
|
108 | - 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
109 | - ], |
|
110 | - 'datetimeIdIn' => [ |
|
111 | - 'type' => ['list_of' => 'Int'], |
|
112 | - 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
113 | - ], |
|
114 | - ], |
|
115 | - $args |
|
116 | - ); |
|
117 | - } |
|
81 | + /** |
|
82 | + * Given an optional array of args, this returns the args to be used in the connection |
|
83 | + * |
|
84 | + * @access public |
|
85 | + * @param array $args The args to modify the defaults |
|
86 | + * |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
90 | + public static function get_connection_args($args = []) |
|
91 | + { |
|
92 | + return array_merge( |
|
93 | + [ |
|
94 | + 'orderby' => [ |
|
95 | + 'type' => ['list_of' => 'TicketsConnectionOrderbyInput'], |
|
96 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
97 | + ], |
|
98 | + 'datetime' => [ |
|
99 | + 'type' => 'ID', |
|
100 | + 'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), |
|
101 | + ], |
|
102 | + 'datetimeIn' => [ |
|
103 | + 'type' => ['list_of' => 'ID'], |
|
104 | + 'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), |
|
105 | + ], |
|
106 | + 'datetimeId' => [ |
|
107 | + 'type' => 'Int', |
|
108 | + 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
109 | + ], |
|
110 | + 'datetimeIdIn' => [ |
|
111 | + 'type' => ['list_of' => 'Int'], |
|
112 | + 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
113 | + ], |
|
114 | + ], |
|
115 | + $args |
|
116 | + ); |
|
117 | + } |
|
118 | 118 | } |
@@ -38,8 +38,8 @@ |
||
38 | 38 | public function config() |
39 | 39 | { |
40 | 40 | return [ |
41 | - 'fromType' => $this->namespace . 'Datetime', |
|
42 | - 'toType' => $this->namespace . 'Ticket', |
|
41 | + 'fromType' => $this->namespace.'Datetime', |
|
42 | + 'toType' => $this->namespace.'Ticket', |
|
43 | 43 | 'fromFieldName' => 'tickets', |
44 | 44 | 'connectionTypeName' => "{$this->namespace}DatetimeTicketsConnection", |
45 | 45 | 'connectionArgs' => self::get_connection_args(), |