@@ -19,107 +19,107 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * AttendeeConnection constructor. |
|
24 | - * |
|
25 | - * @param EEM_Attendee $model |
|
26 | - */ |
|
27 | - public function __construct(EEM_Attendee $model) |
|
28 | - { |
|
29 | - $this->model = $model; |
|
30 | - } |
|
22 | + /** |
|
23 | + * AttendeeConnection constructor. |
|
24 | + * |
|
25 | + * @param EEM_Attendee $model |
|
26 | + */ |
|
27 | + public function __construct(EEM_Attendee $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 . 'Attendee', |
|
42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Attendees', |
|
43 | - 'connectionTypeName' => "{$this->namespace}RootQueryAttendeesConnection", |
|
44 | - 'connectionArgs' => self::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function config() |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => 'RootQuery', |
|
41 | + 'toType' => $this->namespace . 'Attendee', |
|
42 | + 'fromFieldName' => lcfirst($this->namespace) . 'Attendees', |
|
43 | + 'connectionTypeName' => "{$this->namespace}RootQueryAttendeesConnection", |
|
44 | + 'connectionArgs' => self::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return AttendeeConnectionResolver |
|
56 | - * @throws Exception |
|
57 | - * @since $VID:$ |
|
58 | - */ |
|
59 | - public function getConnectionResolver($entity, $args, $context, $info) |
|
60 | - { |
|
61 | - return new AttendeeConnectionResolver($entity, $args, $context, $info); |
|
62 | - } |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return AttendeeConnectionResolver |
|
56 | + * @throws Exception |
|
57 | + * @since $VID:$ |
|
58 | + */ |
|
59 | + public function getConnectionResolver($entity, $args, $context, $info) |
|
60 | + { |
|
61 | + return new AttendeeConnectionResolver($entity, $args, $context, $info); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Given an optional array of args, this returns the args to be used in the connection |
|
66 | - * |
|
67 | - * @access public |
|
68 | - * @param array $args The args to modify the defaults |
|
69 | - * |
|
70 | - * @return array |
|
71 | - */ |
|
72 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
73 | - public static function get_connection_args($args = []) |
|
74 | - { |
|
75 | - return array_merge( |
|
76 | - [ |
|
77 | - 'event' => [ |
|
78 | - 'type' => 'ID', |
|
79 | - 'description' => esc_html__( |
|
80 | - 'Globally unique event ID to get the attendees for.', |
|
81 | - 'event_espresso' |
|
82 | - ), |
|
83 | - ], |
|
84 | - 'eventIn' => [ |
|
85 | - 'type' => ['list_of' => 'ID'], |
|
86 | - 'description' => esc_html__( |
|
87 | - 'Globally unique event IDs to get the attendees for.', |
|
88 | - 'event_espresso' |
|
89 | - ), |
|
90 | - ], |
|
91 | - 'orderby' => [ |
|
92 | - 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], |
|
93 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
94 | - ], |
|
95 | - 'regTicket' => [ |
|
96 | - 'type' => 'ID', |
|
97 | - 'description' => esc_html__( |
|
98 | - 'Globally unique registration ticket ID to get the attendees for.', |
|
99 | - 'event_espresso' |
|
100 | - ), |
|
101 | - ], |
|
102 | - 'regTicketIn' => [ |
|
103 | - 'type' => ['list_of' => 'ID'], |
|
104 | - 'description' => esc_html__( |
|
105 | - 'Globally unique registration ticket IDs to get the attendees for.', |
|
106 | - 'event_espresso' |
|
107 | - ), |
|
108 | - ], |
|
109 | - 'regTicketId' => [ |
|
110 | - 'type' => 'Int', |
|
111 | - 'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), |
|
112 | - ], |
|
113 | - 'regTicketIdIn' => [ |
|
114 | - 'type' => ['list_of' => 'Int'], |
|
115 | - 'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), |
|
116 | - ], |
|
117 | - 'regStatus' => [ |
|
118 | - 'type' => 'EspressoRegistrationStatusEnum', |
|
119 | - 'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), |
|
120 | - ], |
|
121 | - ], |
|
122 | - $args |
|
123 | - ); |
|
124 | - } |
|
64 | + /** |
|
65 | + * Given an optional array of args, this returns the args to be used in the connection |
|
66 | + * |
|
67 | + * @access public |
|
68 | + * @param array $args The args to modify the defaults |
|
69 | + * |
|
70 | + * @return array |
|
71 | + */ |
|
72 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
73 | + public static function get_connection_args($args = []) |
|
74 | + { |
|
75 | + return array_merge( |
|
76 | + [ |
|
77 | + 'event' => [ |
|
78 | + 'type' => 'ID', |
|
79 | + 'description' => esc_html__( |
|
80 | + 'Globally unique event ID to get the attendees for.', |
|
81 | + 'event_espresso' |
|
82 | + ), |
|
83 | + ], |
|
84 | + 'eventIn' => [ |
|
85 | + 'type' => ['list_of' => 'ID'], |
|
86 | + 'description' => esc_html__( |
|
87 | + 'Globally unique event IDs to get the attendees for.', |
|
88 | + 'event_espresso' |
|
89 | + ), |
|
90 | + ], |
|
91 | + 'orderby' => [ |
|
92 | + 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], |
|
93 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
94 | + ], |
|
95 | + 'regTicket' => [ |
|
96 | + 'type' => 'ID', |
|
97 | + 'description' => esc_html__( |
|
98 | + 'Globally unique registration ticket ID to get the attendees for.', |
|
99 | + 'event_espresso' |
|
100 | + ), |
|
101 | + ], |
|
102 | + 'regTicketIn' => [ |
|
103 | + 'type' => ['list_of' => 'ID'], |
|
104 | + 'description' => esc_html__( |
|
105 | + 'Globally unique registration ticket IDs to get the attendees for.', |
|
106 | + 'event_espresso' |
|
107 | + ), |
|
108 | + ], |
|
109 | + 'regTicketId' => [ |
|
110 | + 'type' => 'Int', |
|
111 | + 'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), |
|
112 | + ], |
|
113 | + 'regTicketIdIn' => [ |
|
114 | + 'type' => ['list_of' => 'Int'], |
|
115 | + 'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), |
|
116 | + ], |
|
117 | + 'regStatus' => [ |
|
118 | + 'type' => 'EspressoRegistrationStatusEnum', |
|
119 | + 'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), |
|
120 | + ], |
|
121 | + ], |
|
122 | + $args |
|
123 | + ); |
|
124 | + } |
|
125 | 125 | } |
@@ -14,141 +14,141 @@ |
||
14 | 14 | */ |
15 | 15 | class AttendeeConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - public function get_loader_name() |
|
19 | - { |
|
20 | - return 'espresso_attendee'; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @return EEM_Attendee |
|
25 | - * @throws EE_Error |
|
26 | - * @throws InvalidArgumentException |
|
27 | - * @throws InvalidDataTypeException |
|
28 | - * @throws InvalidInterfaceException |
|
29 | - */ |
|
30 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
31 | - public function get_query() |
|
32 | - { |
|
33 | - return EEM_Attendee::instance(); |
|
34 | - } |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * Return an array of item IDs from the query |
|
39 | - * |
|
40 | - * @return array |
|
41 | - */ |
|
42 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | - public function get_ids() |
|
44 | - { |
|
45 | - $results = $this->query->get_col($this->query_args); |
|
46 | - |
|
47 | - return ! empty($results) ? $results : []; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Determine whether the Query should execute. If it's determined that the query should |
|
53 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
54 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
55 | - * Return false to prevent the query from executing. |
|
56 | - * |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
60 | - public function should_execute() |
|
61 | - { |
|
62 | - if (false === $this->should_execute) { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - return $this->should_execute; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
72 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
73 | - * handle batch resolution of the posts. |
|
74 | - * |
|
75 | - * @return array |
|
76 | - * @throws EE_Error |
|
77 | - * @throws InvalidArgumentException |
|
78 | - * @throws ReflectionException |
|
79 | - * @throws InvalidDataTypeException |
|
80 | - * @throws InvalidInterfaceException |
|
81 | - */ |
|
82 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
83 | - public function get_query_args() |
|
84 | - { |
|
85 | - $where_params = []; |
|
86 | - $query_args = []; |
|
87 | - |
|
88 | - $query_args['limit'] = $this->getLimit(); |
|
89 | - |
|
90 | - // Avoid multiple entries by join. |
|
91 | - $query_args['group_by'] = 'ATT_ID'; |
|
92 | - |
|
93 | - $query_args['default_where_conditions'] = 'minimum'; |
|
94 | - |
|
95 | - /** |
|
96 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
97 | - */ |
|
98 | - $input_fields = []; |
|
99 | - if (! empty($this->args['where'])) { |
|
100 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
101 | - |
|
102 | - // Use the proper operator. |
|
103 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
104 | - $input_fields['Registration.Ticket.TKT_ID'] = ['in', $input_fields['Registration.Ticket.TKT_ID']]; |
|
105 | - } |
|
106 | - // Use the proper operator. |
|
107 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
108 | - $input_fields['Registration.Event.EVT_ID'] = ['in', $input_fields['Registration.Event.EVT_ID']]; |
|
109 | - } |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Merge the input_fields with the default query_args |
|
114 | - */ |
|
115 | - if (! empty($input_fields)) { |
|
116 | - $where_params = array_merge($where_params, $input_fields); |
|
117 | - } |
|
118 | - |
|
119 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
120 | - |
|
121 | - $query_args[] = $where_params; |
|
122 | - |
|
123 | - /** |
|
124 | - * Return the $query_args |
|
125 | - */ |
|
126 | - return $query_args; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | - * friendly keys. |
|
133 | - * |
|
134 | - * @param array $where_args |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function sanitizeInputFields(array $where_args) |
|
138 | - { |
|
139 | - $arg_mapping = [ |
|
140 | - 'event' => 'Registration.Event.EVT_ID', |
|
141 | - 'eventIn' => 'Registration.Event.EVT_ID', |
|
142 | - 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
143 | - 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
144 | - 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
145 | - 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
146 | - 'regStatus' => 'Registration.Status.STS_ID', |
|
147 | - ]; |
|
148 | - return $this->sanitizeWhereArgsForInputFields( |
|
149 | - $where_args, |
|
150 | - $arg_mapping, |
|
151 | - ['event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
152 | - ); |
|
153 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + public function get_loader_name() |
|
19 | + { |
|
20 | + return 'espresso_attendee'; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @return EEM_Attendee |
|
25 | + * @throws EE_Error |
|
26 | + * @throws InvalidArgumentException |
|
27 | + * @throws InvalidDataTypeException |
|
28 | + * @throws InvalidInterfaceException |
|
29 | + */ |
|
30 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
31 | + public function get_query() |
|
32 | + { |
|
33 | + return EEM_Attendee::instance(); |
|
34 | + } |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * Return an array of item IDs from the query |
|
39 | + * |
|
40 | + * @return array |
|
41 | + */ |
|
42 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
43 | + public function get_ids() |
|
44 | + { |
|
45 | + $results = $this->query->get_col($this->query_args); |
|
46 | + |
|
47 | + return ! empty($results) ? $results : []; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Determine whether the Query should execute. If it's determined that the query should |
|
53 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
54 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
55 | + * Return false to prevent the query from executing. |
|
56 | + * |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
60 | + public function should_execute() |
|
61 | + { |
|
62 | + if (false === $this->should_execute) { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + return $this->should_execute; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
72 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
73 | + * handle batch resolution of the posts. |
|
74 | + * |
|
75 | + * @return array |
|
76 | + * @throws EE_Error |
|
77 | + * @throws InvalidArgumentException |
|
78 | + * @throws ReflectionException |
|
79 | + * @throws InvalidDataTypeException |
|
80 | + * @throws InvalidInterfaceException |
|
81 | + */ |
|
82 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
83 | + public function get_query_args() |
|
84 | + { |
|
85 | + $where_params = []; |
|
86 | + $query_args = []; |
|
87 | + |
|
88 | + $query_args['limit'] = $this->getLimit(); |
|
89 | + |
|
90 | + // Avoid multiple entries by join. |
|
91 | + $query_args['group_by'] = 'ATT_ID'; |
|
92 | + |
|
93 | + $query_args['default_where_conditions'] = 'minimum'; |
|
94 | + |
|
95 | + /** |
|
96 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
97 | + */ |
|
98 | + $input_fields = []; |
|
99 | + if (! empty($this->args['where'])) { |
|
100 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
101 | + |
|
102 | + // Use the proper operator. |
|
103 | + if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
104 | + $input_fields['Registration.Ticket.TKT_ID'] = ['in', $input_fields['Registration.Ticket.TKT_ID']]; |
|
105 | + } |
|
106 | + // Use the proper operator. |
|
107 | + if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
108 | + $input_fields['Registration.Event.EVT_ID'] = ['in', $input_fields['Registration.Event.EVT_ID']]; |
|
109 | + } |
|
110 | + } |
|
111 | + |
|
112 | + /** |
|
113 | + * Merge the input_fields with the default query_args |
|
114 | + */ |
|
115 | + if (! empty($input_fields)) { |
|
116 | + $where_params = array_merge($where_params, $input_fields); |
|
117 | + } |
|
118 | + |
|
119 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
120 | + |
|
121 | + $query_args[] = $where_params; |
|
122 | + |
|
123 | + /** |
|
124 | + * Return the $query_args |
|
125 | + */ |
|
126 | + return $query_args; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | + * friendly keys. |
|
133 | + * |
|
134 | + * @param array $where_args |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function sanitizeInputFields(array $where_args) |
|
138 | + { |
|
139 | + $arg_mapping = [ |
|
140 | + 'event' => 'Registration.Event.EVT_ID', |
|
141 | + 'eventIn' => 'Registration.Event.EVT_ID', |
|
142 | + 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
143 | + 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
144 | + 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
145 | + 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
146 | + 'regStatus' => 'Registration.Status.STS_ID', |
|
147 | + ]; |
|
148 | + return $this->sanitizeWhereArgsForInputFields( |
|
149 | + $where_args, |
|
150 | + $arg_mapping, |
|
151 | + ['event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
152 | + ); |
|
153 | + } |
|
154 | 154 | } |
@@ -96,15 +96,15 @@ discard block |
||
96 | 96 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
97 | 97 | */ |
98 | 98 | $input_fields = []; |
99 | - if (! empty($this->args['where'])) { |
|
99 | + if ( ! empty($this->args['where'])) { |
|
100 | 100 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
101 | 101 | |
102 | 102 | // Use the proper operator. |
103 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
103 | + if ( ! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
104 | 104 | $input_fields['Registration.Ticket.TKT_ID'] = ['in', $input_fields['Registration.Ticket.TKT_ID']]; |
105 | 105 | } |
106 | 106 | // Use the proper operator. |
107 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
107 | + if ( ! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
108 | 108 | $input_fields['Registration.Event.EVT_ID'] = ['in', $input_fields['Registration.Event.EVT_ID']]; |
109 | 109 | } |
110 | 110 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | /** |
113 | 113 | * Merge the input_fields with the default query_args |
114 | 114 | */ |
115 | - if (! empty($input_fields)) { |
|
115 | + if ( ! empty($input_fields)) { |
|
116 | 116 | $where_params = array_merge($where_params, $input_fields); |
117 | 117 | } |
118 | 118 |