@@ -17,179 +17,179 @@ |
||
| 17 | 17 | class TicketConnectionResolver extends AbstractConnectionResolver |
| 18 | 18 | { |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * @return EEM_Ticket |
|
| 22 | - * @throws EE_Error |
|
| 23 | - * @throws InvalidArgumentException |
|
| 24 | - * @throws InvalidDataTypeException |
|
| 25 | - * @throws InvalidInterfaceException |
|
| 26 | - */ |
|
| 27 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 28 | - public function get_query() |
|
| 29 | - { |
|
| 30 | - return EEM_Ticket::instance(); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Return an array of items from the query |
|
| 36 | - * |
|
| 37 | - * @return array |
|
| 38 | - */ |
|
| 39 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 40 | - public function get_items() |
|
| 41 | - { |
|
| 42 | - $results = $this->query->get_col($this->query_args); |
|
| 43 | - |
|
| 44 | - return ! empty($results) ? $results : []; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * Determine whether the Query should execute. If it's determined that the query should |
|
| 50 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
| 51 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
| 52 | - * Return false to prevent the query from executing. |
|
| 53 | - * |
|
| 54 | - * @return bool |
|
| 55 | - */ |
|
| 56 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 57 | - public function should_execute() |
|
| 58 | - { |
|
| 59 | - if (false === $this->should_execute) { |
|
| 60 | - return false; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - return $this->should_execute; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
| 69 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
| 70 | - * handle batch resolution of the posts. |
|
| 71 | - * |
|
| 72 | - * @return array |
|
| 73 | - * @throws EE_Error |
|
| 74 | - * @throws InvalidArgumentException |
|
| 75 | - * @throws ReflectionException |
|
| 76 | - * @throws InvalidDataTypeException |
|
| 77 | - * @throws InvalidInterfaceException |
|
| 78 | - */ |
|
| 79 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 80 | - public function get_query_args() |
|
| 81 | - { |
|
| 82 | - $where_params = []; |
|
| 83 | - $query_args = []; |
|
| 84 | - /** |
|
| 85 | - * Prepare for later use |
|
| 86 | - */ |
|
| 87 | - $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
| 88 | - $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
| 92 | - */ |
|
| 93 | - $query_args['limit'] = min( |
|
| 94 | - max(absint($first), absint($last), 10), |
|
| 95 | - $this->query_amount |
|
| 96 | - ) + 1; |
|
| 97 | - |
|
| 98 | - // Avoid multiple entries by join. |
|
| 99 | - $query_args['group_by'] = 'TKT_ID'; |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
| 103 | - */ |
|
| 104 | - $input_fields = []; |
|
| 105 | - if (! empty($this->args['where'])) { |
|
| 106 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
| 107 | - |
|
| 108 | - // Use the proper operator. |
|
| 109 | - if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
| 110 | - $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
| 116 | - */ |
|
| 117 | - if ($this->source instanceof EE_Datetime) { |
|
| 118 | - $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - /** |
|
| 122 | - * Merge the input_fields with the default query_args |
|
| 123 | - */ |
|
| 124 | - if (! empty($input_fields)) { |
|
| 125 | - $where_params = array_merge($where_params, $input_fields); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // ID of the offset datetime. |
|
| 129 | - $offset = $this->get_offset(); |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Map the orderby inputArgs to the WP_Query |
|
| 133 | - */ |
|
| 134 | - if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
| 135 | - $query_args['order_by'] = []; |
|
| 136 | - foreach ($this->args['where']['orderby'] as $orderby_input) { |
|
| 137 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
| 138 | - } |
|
| 139 | - } elseif ($offset) { |
|
| 140 | - $compare = ! empty($last) ? '<' : '>'; |
|
| 141 | - $where_params['TKT_ID'] = array($compare, $offset); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $query_args[] = $where_params; |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Return the $query_args |
|
| 148 | - */ |
|
| 149 | - return $query_args; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
| 155 | - * friendly keys. |
|
| 156 | - * |
|
| 157 | - * @param array $where_args |
|
| 158 | - * @return array |
|
| 159 | - */ |
|
| 160 | - public function sanitizeInputFields(array $where_args) |
|
| 161 | - { |
|
| 162 | - $arg_mapping = [ |
|
| 163 | - 'datetimeIn' => 'Datetime.DTT_ID', |
|
| 164 | - 'datetimeId' => 'Datetime.DTT_ID', // preferred. |
|
| 165 | - ]; |
|
| 166 | - |
|
| 167 | - $query_args = []; |
|
| 168 | - |
|
| 169 | - foreach ($where_args as $arg => $value) { |
|
| 170 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
| 171 | - continue; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - if (is_array($value) && ! empty($value)) { |
|
| 175 | - $value = array_map( |
|
| 176 | - function ($value) { |
|
| 177 | - if (is_string($value)) { |
|
| 178 | - $value = sanitize_text_field($value); |
|
| 179 | - } |
|
| 180 | - return $value; |
|
| 181 | - }, |
|
| 182 | - $value |
|
| 183 | - ); |
|
| 184 | - } elseif (is_string($value)) { |
|
| 185 | - $value = sanitize_text_field($value); |
|
| 186 | - } |
|
| 187 | - $query_args[ $arg_mapping[ $arg ] ] = $value; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * Return the Query Args |
|
| 192 | - */ |
|
| 193 | - return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
| 194 | - } |
|
| 20 | + /** |
|
| 21 | + * @return EEM_Ticket |
|
| 22 | + * @throws EE_Error |
|
| 23 | + * @throws InvalidArgumentException |
|
| 24 | + * @throws InvalidDataTypeException |
|
| 25 | + * @throws InvalidInterfaceException |
|
| 26 | + */ |
|
| 27 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 28 | + public function get_query() |
|
| 29 | + { |
|
| 30 | + return EEM_Ticket::instance(); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Return an array of items from the query |
|
| 36 | + * |
|
| 37 | + * @return array |
|
| 38 | + */ |
|
| 39 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 40 | + public function get_items() |
|
| 41 | + { |
|
| 42 | + $results = $this->query->get_col($this->query_args); |
|
| 43 | + |
|
| 44 | + return ! empty($results) ? $results : []; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * Determine whether the Query should execute. If it's determined that the query should |
|
| 50 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
| 51 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
| 52 | + * Return false to prevent the query from executing. |
|
| 53 | + * |
|
| 54 | + * @return bool |
|
| 55 | + */ |
|
| 56 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 57 | + public function should_execute() |
|
| 58 | + { |
|
| 59 | + if (false === $this->should_execute) { |
|
| 60 | + return false; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + return $this->should_execute; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
| 69 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
| 70 | + * handle batch resolution of the posts. |
|
| 71 | + * |
|
| 72 | + * @return array |
|
| 73 | + * @throws EE_Error |
|
| 74 | + * @throws InvalidArgumentException |
|
| 75 | + * @throws ReflectionException |
|
| 76 | + * @throws InvalidDataTypeException |
|
| 77 | + * @throws InvalidInterfaceException |
|
| 78 | + */ |
|
| 79 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 80 | + public function get_query_args() |
|
| 81 | + { |
|
| 82 | + $where_params = []; |
|
| 83 | + $query_args = []; |
|
| 84 | + /** |
|
| 85 | + * Prepare for later use |
|
| 86 | + */ |
|
| 87 | + $last = ! empty($this->args['last']) ? $this->args['last'] : null; |
|
| 88 | + $first = ! empty($this->args['first']) ? $this->args['first'] : null; |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Set limit the highest value of $first and $last, with a (filterable) max of 100 |
|
| 92 | + */ |
|
| 93 | + $query_args['limit'] = min( |
|
| 94 | + max(absint($first), absint($last), 10), |
|
| 95 | + $this->query_amount |
|
| 96 | + ) + 1; |
|
| 97 | + |
|
| 98 | + // Avoid multiple entries by join. |
|
| 99 | + $query_args['group_by'] = 'TKT_ID'; |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
| 103 | + */ |
|
| 104 | + $input_fields = []; |
|
| 105 | + if (! empty($this->args['where'])) { |
|
| 106 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
| 107 | + |
|
| 108 | + // Use the proper operator. |
|
| 109 | + if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
| 110 | + $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
| 116 | + */ |
|
| 117 | + if ($this->source instanceof EE_Datetime) { |
|
| 118 | + $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + /** |
|
| 122 | + * Merge the input_fields with the default query_args |
|
| 123 | + */ |
|
| 124 | + if (! empty($input_fields)) { |
|
| 125 | + $where_params = array_merge($where_params, $input_fields); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // ID of the offset datetime. |
|
| 129 | + $offset = $this->get_offset(); |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Map the orderby inputArgs to the WP_Query |
|
| 133 | + */ |
|
| 134 | + if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
| 135 | + $query_args['order_by'] = []; |
|
| 136 | + foreach ($this->args['where']['orderby'] as $orderby_input) { |
|
| 137 | + $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
| 138 | + } |
|
| 139 | + } elseif ($offset) { |
|
| 140 | + $compare = ! empty($last) ? '<' : '>'; |
|
| 141 | + $where_params['TKT_ID'] = array($compare, $offset); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $query_args[] = $where_params; |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Return the $query_args |
|
| 148 | + */ |
|
| 149 | + return $query_args; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
| 155 | + * friendly keys. |
|
| 156 | + * |
|
| 157 | + * @param array $where_args |
|
| 158 | + * @return array |
|
| 159 | + */ |
|
| 160 | + public function sanitizeInputFields(array $where_args) |
|
| 161 | + { |
|
| 162 | + $arg_mapping = [ |
|
| 163 | + 'datetimeIn' => 'Datetime.DTT_ID', |
|
| 164 | + 'datetimeId' => 'Datetime.DTT_ID', // preferred. |
|
| 165 | + ]; |
|
| 166 | + |
|
| 167 | + $query_args = []; |
|
| 168 | + |
|
| 169 | + foreach ($where_args as $arg => $value) { |
|
| 170 | + if (! array_key_exists($arg, $arg_mapping)) { |
|
| 171 | + continue; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + if (is_array($value) && ! empty($value)) { |
|
| 175 | + $value = array_map( |
|
| 176 | + function ($value) { |
|
| 177 | + if (is_string($value)) { |
|
| 178 | + $value = sanitize_text_field($value); |
|
| 179 | + } |
|
| 180 | + return $value; |
|
| 181 | + }, |
|
| 182 | + $value |
|
| 183 | + ); |
|
| 184 | + } elseif (is_string($value)) { |
|
| 185 | + $value = sanitize_text_field($value); |
|
| 186 | + } |
|
| 187 | + $query_args[ $arg_mapping[ $arg ] ] = $value; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * Return the Query Args |
|
| 192 | + */ |
|
| 193 | + return ! empty($query_args) && is_array($query_args) ? $query_args : []; |
|
| 194 | + } |
|
| 195 | 195 | } |
@@ -102,11 +102,11 @@ discard block |
||
| 102 | 102 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
| 103 | 103 | */ |
| 104 | 104 | $input_fields = []; |
| 105 | - if (! empty($this->args['where'])) { |
|
| 105 | + if ( ! empty($this->args['where'])) { |
|
| 106 | 106 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
| 107 | 107 | |
| 108 | 108 | // Use the proper operator. |
| 109 | - if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
| 109 | + if ( ! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
| 110 | 110 | $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; |
| 111 | 111 | } |
| 112 | 112 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | /** |
| 122 | 122 | * Merge the input_fields with the default query_args |
| 123 | 123 | */ |
| 124 | - if (! empty($input_fields)) { |
|
| 124 | + if ( ! empty($input_fields)) { |
|
| 125 | 125 | $where_params = array_merge($where_params, $input_fields); |
| 126 | 126 | } |
| 127 | 127 | |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | /** |
| 132 | 132 | * Map the orderby inputArgs to the WP_Query |
| 133 | 133 | */ |
| 134 | - if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
| 134 | + if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
| 135 | 135 | $query_args['order_by'] = []; |
| 136 | 136 | foreach ($this->args['where']['orderby'] as $orderby_input) { |
| 137 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
| 137 | + $query_args['order_by'][$orderby_input['field']] = $orderby_input['order']; |
|
| 138 | 138 | } |
| 139 | 139 | } elseif ($offset) { |
| 140 | 140 | $compare = ! empty($last) ? '<' : '>'; |
@@ -167,13 +167,13 @@ discard block |
||
| 167 | 167 | $query_args = []; |
| 168 | 168 | |
| 169 | 169 | foreach ($where_args as $arg => $value) { |
| 170 | - if (! array_key_exists($arg, $arg_mapping)) { |
|
| 170 | + if ( ! array_key_exists($arg, $arg_mapping)) { |
|
| 171 | 171 | continue; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | if (is_array($value) && ! empty($value)) { |
| 175 | 175 | $value = array_map( |
| 176 | - function ($value) { |
|
| 176 | + function($value) { |
|
| 177 | 177 | if (is_string($value)) { |
| 178 | 178 | $value = sanitize_text_field($value); |
| 179 | 179 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | } elseif (is_string($value)) { |
| 185 | 185 | $value = sanitize_text_field($value); |
| 186 | 186 | } |
| 187 | - $query_args[ $arg_mapping[ $arg ] ] = $value; |
|
| 187 | + $query_args[$arg_mapping[$arg]] = $value; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | /** |
@@ -11,39 +11,39 @@ |
||
| 11 | 11 | class DatetimeMutation |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Maps the GraphQL input to a format that the model functions can use |
|
| 16 | - * |
|
| 17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
| 18 | - * @return array |
|
| 19 | - */ |
|
| 20 | - public static function prepareFields(array $input) |
|
| 21 | - { |
|
| 14 | + /** |
|
| 15 | + * Maps the GraphQL input to a format that the model functions can use |
|
| 16 | + * |
|
| 17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
| 18 | + * @return array |
|
| 19 | + */ |
|
| 20 | + public static function prepareFields(array $input) |
|
| 21 | + { |
|
| 22 | 22 | |
| 23 | - $args = []; |
|
| 23 | + $args = []; |
|
| 24 | 24 | |
| 25 | - if (! empty($input['event'])) { |
|
| 26 | - $args['EVT_ID'] = absint($input['event']); |
|
| 27 | - } |
|
| 25 | + if (! empty($input['event'])) { |
|
| 26 | + $args['EVT_ID'] = absint($input['event']); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - if (! empty($input['name'])) { |
|
| 30 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 31 | - } |
|
| 29 | + if (! empty($input['name'])) { |
|
| 30 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - if (! empty($input['description'])) { |
|
| 34 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 35 | - } |
|
| 33 | + if (! empty($input['description'])) { |
|
| 34 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - if (! empty($input['endDate'])) { |
|
| 38 | - $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
| 39 | - } |
|
| 37 | + if (! empty($input['endDate'])) { |
|
| 38 | + $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - if (! empty($input['endDate'])) { |
|
| 42 | - $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
| 43 | - } |
|
| 41 | + if (! empty($input['endDate'])) { |
|
| 42 | + $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - // Likewise the other fields... |
|
| 45 | + // Likewise the other fields... |
|
| 46 | 46 | |
| 47 | - return $args; |
|
| 48 | - } |
|
| 47 | + return $args; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -22,23 +22,23 @@ |
||
| 22 | 22 | |
| 23 | 23 | $args = []; |
| 24 | 24 | |
| 25 | - if (! empty($input['event'])) { |
|
| 25 | + if ( ! empty($input['event'])) { |
|
| 26 | 26 | $args['EVT_ID'] = absint($input['event']); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if (! empty($input['name'])) { |
|
| 29 | + if ( ! empty($input['name'])) { |
|
| 30 | 30 | $args['DTT_name'] = sanitize_text_field($input['name']); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if (! empty($input['description'])) { |
|
| 33 | + if ( ! empty($input['description'])) { |
|
| 34 | 34 | $args['DTT_description'] = sanitize_text_field($input['description']); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if (! empty($input['endDate'])) { |
|
| 37 | + if ( ! empty($input['endDate'])) { |
|
| 38 | 38 | $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - if (! empty($input['endDate'])) { |
|
| 41 | + if ( ! empty($input['endDate'])) { |
|
| 42 | 42 | $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
| 43 | 43 | } |
| 44 | 44 | |
@@ -11,31 +11,31 @@ |
||
| 11 | 11 | class TicketMutation |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Maps the GraphQL input to a format that the model functions can use |
|
| 16 | - * |
|
| 17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
| 18 | - * @return array |
|
| 19 | - */ |
|
| 20 | - public static function prepareFields(array $input) |
|
| 21 | - { |
|
| 14 | + /** |
|
| 15 | + * Maps the GraphQL input to a format that the model functions can use |
|
| 16 | + * |
|
| 17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
| 18 | + * @return array |
|
| 19 | + */ |
|
| 20 | + public static function prepareFields(array $input) |
|
| 21 | + { |
|
| 22 | 22 | |
| 23 | - $args = []; |
|
| 23 | + $args = []; |
|
| 24 | 24 | |
| 25 | - if (! empty($input['name'])) { |
|
| 26 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 27 | - } |
|
| 25 | + if (! empty($input['name'])) { |
|
| 26 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - if (! empty($input['description'])) { |
|
| 30 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 31 | - } |
|
| 29 | + if (! empty($input['description'])) { |
|
| 30 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - if (! empty($input['price'])) { |
|
| 34 | - $args['TKT_price'] = floatval($input['price']); |
|
| 35 | - } |
|
| 33 | + if (! empty($input['price'])) { |
|
| 34 | + $args['TKT_price'] = floatval($input['price']); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - // Likewise the other fields... |
|
| 37 | + // Likewise the other fields... |
|
| 38 | 38 | |
| 39 | - return $args; |
|
| 40 | - } |
|
| 39 | + return $args; |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -22,15 +22,15 @@ |
||
| 22 | 22 | |
| 23 | 23 | $args = []; |
| 24 | 24 | |
| 25 | - if (! empty($input['name'])) { |
|
| 25 | + if ( ! empty($input['name'])) { |
|
| 26 | 26 | $args['TKT_name'] = sanitize_text_field($input['name']); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - if (! empty($input['description'])) { |
|
| 29 | + if ( ! empty($input['description'])) { |
|
| 30 | 30 | $args['TKT_description'] = sanitize_text_field($input['description']); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if (! empty($input['price'])) { |
|
| 33 | + if ( ! empty($input['price'])) { |
|
| 34 | 34 | $args['TKT_price'] = floatval($input['price']); |
| 35 | 35 | } |
| 36 | 36 | |
@@ -19,97 +19,97 @@ |
||
| 19 | 19 | class DatetimeTicketsConnection implements ConnectionInterface |
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @var EEM_Ticket $model |
|
| 24 | - */ |
|
| 25 | - protected $model; |
|
| 22 | + /** |
|
| 23 | + * @var EEM_Ticket $model |
|
| 24 | + */ |
|
| 25 | + protected $model; |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * DatetimeConnection constructor. |
|
| 30 | - * |
|
| 31 | - * @param EEM_Ticket $model |
|
| 32 | - */ |
|
| 33 | - public function __construct(EEM_Ticket $model) |
|
| 34 | - { |
|
| 35 | - $this->model = $model; |
|
| 36 | - } |
|
| 28 | + /** |
|
| 29 | + * DatetimeConnection constructor. |
|
| 30 | + * |
|
| 31 | + * @param EEM_Ticket $model |
|
| 32 | + */ |
|
| 33 | + public function __construct(EEM_Ticket $model) |
|
| 34 | + { |
|
| 35 | + $this->model = $model; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return array |
|
| 41 | - * @since $VID:$ |
|
| 42 | - */ |
|
| 43 | - public function config() |
|
| 44 | - { |
|
| 45 | - return [ |
|
| 46 | - 'fromType' => 'Datetime', |
|
| 47 | - 'toType' => 'Ticket', |
|
| 48 | - 'fromFieldName' => 'tickets', |
|
| 49 | - 'connectionTypeName' => 'DatetimeTicketsConnection', |
|
| 50 | - 'connectionArgs' => self::get_connection_args(), |
|
| 51 | - 'resolve' => [$this, 'resolveConnection'], |
|
| 52 | - 'resolveNode' => [$this, 'resolveNode'] |
|
| 53 | - ]; |
|
| 54 | - } |
|
| 39 | + /** |
|
| 40 | + * @return array |
|
| 41 | + * @since $VID:$ |
|
| 42 | + */ |
|
| 43 | + public function config() |
|
| 44 | + { |
|
| 45 | + return [ |
|
| 46 | + 'fromType' => 'Datetime', |
|
| 47 | + 'toType' => 'Ticket', |
|
| 48 | + 'fromFieldName' => 'tickets', |
|
| 49 | + 'connectionTypeName' => 'DatetimeTicketsConnection', |
|
| 50 | + 'connectionArgs' => self::get_connection_args(), |
|
| 51 | + 'resolve' => [$this, 'resolveConnection'], |
|
| 52 | + 'resolveNode' => [$this, 'resolveNode'] |
|
| 53 | + ]; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @param $entity |
|
| 59 | - * @param $args |
|
| 60 | - * @param $context |
|
| 61 | - * @param $info |
|
| 62 | - * @return array |
|
| 63 | - * @throws Exception |
|
| 64 | - * @since $VID:$ |
|
| 65 | - */ |
|
| 66 | - public function resolveConnection($entity, $args, $context, $info) |
|
| 67 | - { |
|
| 68 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
| 69 | - return $resolver->get_connection(); |
|
| 70 | - } |
|
| 57 | + /** |
|
| 58 | + * @param $entity |
|
| 59 | + * @param $args |
|
| 60 | + * @param $context |
|
| 61 | + * @param $info |
|
| 62 | + * @return array |
|
| 63 | + * @throws Exception |
|
| 64 | + * @since $VID:$ |
|
| 65 | + */ |
|
| 66 | + public function resolveConnection($entity, $args, $context, $info) |
|
| 67 | + { |
|
| 68 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
|
| 69 | + return $resolver->get_connection(); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @param $id |
|
| 75 | - * @param $args |
|
| 76 | - * @param $context |
|
| 77 | - * @param $info |
|
| 78 | - * @return EE_Base_Class |
|
| 79 | - * @since $VID:$ |
|
| 80 | - */ |
|
| 81 | - public function resolveNode($id, $args, $context, $info) |
|
| 82 | - { |
|
| 83 | - return $this->model->get_one_by_ID($id); |
|
| 84 | - } |
|
| 73 | + /** |
|
| 74 | + * @param $id |
|
| 75 | + * @param $args |
|
| 76 | + * @param $context |
|
| 77 | + * @param $info |
|
| 78 | + * @return EE_Base_Class |
|
| 79 | + * @since $VID:$ |
|
| 80 | + */ |
|
| 81 | + public function resolveNode($id, $args, $context, $info) |
|
| 82 | + { |
|
| 83 | + return $this->model->get_one_by_ID($id); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * Given an optional array of args, this returns the args to be used in the connection |
|
| 88 | - * |
|
| 89 | - * @access public |
|
| 90 | - * @param array $args The args to modify the defaults |
|
| 91 | - * |
|
| 92 | - * @return array |
|
| 93 | - */ |
|
| 94 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 95 | - public static function get_connection_args($args = []) |
|
| 96 | - { |
|
| 97 | - return array_merge( |
|
| 98 | - [ |
|
| 99 | - 'orderby' => [ |
|
| 100 | - 'type' => ['list_of' => 'TicketsConnectionOrderbyInput'], |
|
| 101 | - 'description' => esc_html__('What paramater to use to order the objects by.', 'event_espresso'), |
|
| 102 | - ], |
|
| 103 | - 'datetimeId' => [ |
|
| 104 | - 'type' => 'Int', |
|
| 105 | - 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
| 106 | - ], |
|
| 107 | - 'datetimeIn' => [ |
|
| 108 | - 'type' => ['list_of' => 'Int'], |
|
| 109 | - 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
| 110 | - ], |
|
| 111 | - ], |
|
| 112 | - $args |
|
| 113 | - ); |
|
| 114 | - } |
|
| 86 | + /** |
|
| 87 | + * Given an optional array of args, this returns the args to be used in the connection |
|
| 88 | + * |
|
| 89 | + * @access public |
|
| 90 | + * @param array $args The args to modify the defaults |
|
| 91 | + * |
|
| 92 | + * @return array |
|
| 93 | + */ |
|
| 94 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 95 | + public static function get_connection_args($args = []) |
|
| 96 | + { |
|
| 97 | + return array_merge( |
|
| 98 | + [ |
|
| 99 | + 'orderby' => [ |
|
| 100 | + 'type' => ['list_of' => 'TicketsConnectionOrderbyInput'], |
|
| 101 | + 'description' => esc_html__('What paramater to use to order the objects by.', 'event_espresso'), |
|
| 102 | + ], |
|
| 103 | + 'datetimeId' => [ |
|
| 104 | + 'type' => 'Int', |
|
| 105 | + 'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), |
|
| 106 | + ], |
|
| 107 | + 'datetimeIn' => [ |
|
| 108 | + 'type' => ['list_of' => 'Int'], |
|
| 109 | + 'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), |
|
| 110 | + ], |
|
| 111 | + ], |
|
| 112 | + $args |
|
| 113 | + ); |
|
| 114 | + } |
|
| 115 | 115 | } |