| @@ -20,95 +20,95 @@ | ||
| 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 | - ]; | |
| 48 | - } | |
| 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 | + ]; | |
| 48 | + } | |
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** | |
| 52 | - * @param $entity | |
| 53 | - * @param $args | |
| 54 | - * @param $context | |
| 55 | - * @param $info | |
| 56 | - * @return array | |
| 57 | - * @throws Exception | |
| 58 | - * @since $VID:$ | |
| 59 | - */ | |
| 60 | - public function resolveConnection($entity, $args, $context, $info) | |
| 61 | -    { | |
| 62 | - $resolver = new TicketConnectionResolver($entity, $args, $context, $info); | |
| 63 | - return $resolver->get_connection(); | |
| 64 | - } | |
| 51 | + /** | |
| 52 | + * @param $entity | |
| 53 | + * @param $args | |
| 54 | + * @param $context | |
| 55 | + * @param $info | |
| 56 | + * @return array | |
| 57 | + * @throws Exception | |
| 58 | + * @since $VID:$ | |
| 59 | + */ | |
| 60 | + public function resolveConnection($entity, $args, $context, $info) | |
| 61 | +	{ | |
| 62 | + $resolver = new TicketConnectionResolver($entity, $args, $context, $info); | |
| 63 | + return $resolver->get_connection(); | |
| 64 | + } | |
| 65 | 65 | |
| 66 | - /** | |
| 67 | - * Given an optional array of args, this returns the args to be used in the connection | |
| 68 | - * | |
| 69 | - * @access public | |
| 70 | - * @param array $args The args to modify the defaults | |
| 71 | - * | |
| 72 | - * @return array | |
| 73 | - */ | |
| 74 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 75 | - public static function get_connection_args($args = []) | |
| 76 | -    { | |
| 77 | - $newArgs = [ | |
| 78 | - 'orderby' => [ | |
| 79 | - 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], | |
| 80 | -                'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 81 | - ], | |
| 82 | - 'datetime' => [ | |
| 83 | - 'type' => 'ID', | |
| 84 | -                'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), | |
| 85 | - ], | |
| 86 | - 'datetimeIn' => [ | |
| 87 | - 'type' => ['list_of' => 'ID'], | |
| 88 | -                'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), | |
| 89 | - ], | |
| 90 | - 'datetimeId' => [ | |
| 91 | - 'type' => 'Int', | |
| 92 | -                'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), | |
| 93 | - ], | |
| 94 | - 'datetimeIdIn' => [ | |
| 95 | - 'type' => ['list_of' => 'Int'], | |
| 96 | -                'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), | |
| 97 | - ], | |
| 98 | - 'search' => [ | |
| 99 | - 'type' => 'String', | |
| 100 | -                'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 101 | - ], | |
| 102 | - ]; | |
| 66 | + /** | |
| 67 | + * Given an optional array of args, this returns the args to be used in the connection | |
| 68 | + * | |
| 69 | + * @access public | |
| 70 | + * @param array $args The args to modify the defaults | |
| 71 | + * | |
| 72 | + * @return array | |
| 73 | + */ | |
| 74 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 75 | + public static function get_connection_args($args = []) | |
| 76 | +	{ | |
| 77 | + $newArgs = [ | |
| 78 | + 'orderby' => [ | |
| 79 | + 'type' => ['list_of' => 'EspressoTicketsConnectionOrderbyInput'], | |
| 80 | +				'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 81 | + ], | |
| 82 | + 'datetime' => [ | |
| 83 | + 'type' => 'ID', | |
| 84 | +				'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'), | |
| 85 | + ], | |
| 86 | + 'datetimeIn' => [ | |
| 87 | + 'type' => ['list_of' => 'ID'], | |
| 88 | +				'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'), | |
| 89 | + ], | |
| 90 | + 'datetimeId' => [ | |
| 91 | + 'type' => 'Int', | |
| 92 | +				'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'), | |
| 93 | + ], | |
| 94 | + 'datetimeIdIn' => [ | |
| 95 | + 'type' => ['list_of' => 'Int'], | |
| 96 | +				'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'), | |
| 97 | + ], | |
| 98 | + 'search' => [ | |
| 99 | + 'type' => 'String', | |
| 100 | +				'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 101 | + ], | |
| 102 | + ]; | |
| 103 | 103 | |
| 104 | - $newArgs = apply_filters( | |
| 105 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', | |
| 106 | - $newArgs, | |
| 107 | - $args | |
| 108 | - ); | |
| 109 | - return array_merge( | |
| 110 | - $newArgs, | |
| 111 | - $args | |
| 112 | - ); | |
| 113 | - } | |
| 104 | + $newArgs = apply_filters( | |
| 105 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', | |
| 106 | + $newArgs, | |
| 107 | + $args | |
| 108 | + ); | |
| 109 | + return array_merge( | |
| 110 | + $newArgs, | |
| 111 | + $args | |
| 112 | + ); | |
| 113 | + } | |
| 114 | 114 | } | 
| @@ -21,123 +21,123 @@ | ||
| 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 | - ]; | |
| 49 | - } | |
| 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 | + ]; | |
| 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 DatetimeConnectionResolver($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 DatetimeConnectionResolver($entity, $args, $context, $info); | |
| 64 | + return $resolver->get_connection(); | |
| 65 | + } | |
| 66 | 66 | |
| 67 | - /** | |
| 68 | - * Given an optional array of args, this returns the args to be used in the connection | |
| 69 | - * | |
| 70 | - * @access public | |
| 71 | - * @param array $args The args to modify the defaults | |
| 72 | - * | |
| 73 | - * @return array | |
| 74 | - */ | |
| 75 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 76 | - public static function get_connection_args($args = []) | |
| 77 | -    { | |
| 78 | - $newArgs = [ | |
| 79 | - 'orderby' => [ | |
| 80 | - 'type' => ['list_of' => 'EspressoDatetimesConnectionOrderbyInput'], | |
| 81 | -                'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 82 | - ], | |
| 83 | - 'event' => [ | |
| 84 | - 'type' => 'ID', | |
| 85 | -                'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), | |
| 86 | - ], | |
| 87 | - 'eventIn' => [ | |
| 88 | - 'type' => ['list_of' => 'ID'], | |
| 89 | -                'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), | |
| 90 | - ], | |
| 91 | - 'eventId' => [ | |
| 92 | - 'type' => 'Int', | |
| 93 | -                'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), | |
| 94 | - ], | |
| 95 | - 'eventIdIn' => [ | |
| 96 | - 'type' => ['list_of' => 'Int'], | |
| 97 | -                'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), | |
| 98 | - ], | |
| 99 | - 'ticket' => [ | |
| 100 | - 'type' => 'ID', | |
| 101 | -                'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), | |
| 102 | - ], | |
| 103 | - 'ticketIn' => [ | |
| 104 | - 'type' => ['list_of' => 'ID'], | |
| 105 | -                'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), | |
| 106 | - ], | |
| 107 | - 'ticketId' => [ | |
| 108 | - 'type' => 'Int', | |
| 109 | -                'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), | |
| 110 | - ], | |
| 111 | - 'ticketIdIn' => [ | |
| 112 | - 'type' => ['list_of' => 'Int'], | |
| 113 | -                'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), | |
| 114 | - ], | |
| 115 | - 'upcoming' => [ | |
| 116 | - 'type' => 'Boolean', | |
| 117 | -                'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), | |
| 118 | - ], | |
| 119 | - 'active' => [ | |
| 120 | - 'type' => 'Boolean', | |
| 121 | -                'description' => esc_html__('Datetimes which are active.', 'event_espresso'), | |
| 122 | - ], | |
| 123 | - 'expired' => [ | |
| 124 | - 'type' => 'Boolean', | |
| 125 | -                'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), | |
| 126 | - ], | |
| 127 | - 'search' => [ | |
| 128 | - 'type' => 'String', | |
| 129 | -                'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 130 | - ], | |
| 131 | - ]; | |
| 67 | + /** | |
| 68 | + * Given an optional array of args, this returns the args to be used in the connection | |
| 69 | + * | |
| 70 | + * @access public | |
| 71 | + * @param array $args The args to modify the defaults | |
| 72 | + * | |
| 73 | + * @return array | |
| 74 | + */ | |
| 75 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 76 | + public static function get_connection_args($args = []) | |
| 77 | +	{ | |
| 78 | + $newArgs = [ | |
| 79 | + 'orderby' => [ | |
| 80 | + 'type' => ['list_of' => 'EspressoDatetimesConnectionOrderbyInput'], | |
| 81 | +				'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 82 | + ], | |
| 83 | + 'event' => [ | |
| 84 | + 'type' => 'ID', | |
| 85 | +				'description' => esc_html__('Globally unique event ID to get the datetimes for.', 'event_espresso'), | |
| 86 | + ], | |
| 87 | + 'eventIn' => [ | |
| 88 | + 'type' => ['list_of' => 'ID'], | |
| 89 | +				'description' => esc_html__('Globally unique event IDs to get the datetimes for.', 'event_espresso'), | |
| 90 | + ], | |
| 91 | + 'eventId' => [ | |
| 92 | + 'type' => 'Int', | |
| 93 | +				'description' => esc_html__('Event ID to get the datetimes for.', 'event_espresso'), | |
| 94 | + ], | |
| 95 | + 'eventIdIn' => [ | |
| 96 | + 'type' => ['list_of' => 'Int'], | |
| 97 | +				'description' => esc_html__('Event IDs to get the datetimes for.', 'event_espresso'), | |
| 98 | + ], | |
| 99 | + 'ticket' => [ | |
| 100 | + 'type' => 'ID', | |
| 101 | +				'description' => esc_html__('Globally unique ticket ID to get the datetimes for.', 'event_espresso'), | |
| 102 | + ], | |
| 103 | + 'ticketIn' => [ | |
| 104 | + 'type' => ['list_of' => 'ID'], | |
| 105 | +				'description' => esc_html__('Globally unique ticket IDs to get the datetimes for.', 'event_espresso'), | |
| 106 | + ], | |
| 107 | + 'ticketId' => [ | |
| 108 | + 'type' => 'Int', | |
| 109 | +				'description' => esc_html__('Ticket ID to get the datetimes for.', 'event_espresso'), | |
| 110 | + ], | |
| 111 | + 'ticketIdIn' => [ | |
| 112 | + 'type' => ['list_of' => 'Int'], | |
| 113 | +				'description' => esc_html__('Ticket IDs to get the datetimes for.', 'event_espresso'), | |
| 114 | + ], | |
| 115 | + 'upcoming' => [ | |
| 116 | + 'type' => 'Boolean', | |
| 117 | +				'description' => esc_html__('Datetimes which are upcoming.', 'event_espresso'), | |
| 118 | + ], | |
| 119 | + 'active' => [ | |
| 120 | + 'type' => 'Boolean', | |
| 121 | +				'description' => esc_html__('Datetimes which are active.', 'event_espresso'), | |
| 122 | + ], | |
| 123 | + 'expired' => [ | |
| 124 | + 'type' => 'Boolean', | |
| 125 | +				'description' => esc_html__('Datetimes which are expired.', 'event_espresso'), | |
| 126 | + ], | |
| 127 | + 'search' => [ | |
| 128 | + 'type' => 'String', | |
| 129 | +				'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 130 | + ], | |
| 131 | + ]; | |
| 132 | 132 | |
| 133 | - $newArgs = apply_filters( | |
| 134 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__datetime_args', | |
| 135 | - $newArgs, | |
| 136 | - $args | |
| 137 | - ); | |
| 138 | - return array_merge( | |
| 139 | - $newArgs, | |
| 140 | - $args | |
| 141 | - ); | |
| 142 | - } | |
| 133 | + $newArgs = apply_filters( | |
| 134 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__datetime_args', | |
| 135 | + $newArgs, | |
| 136 | + $args | |
| 137 | + ); | |
| 138 | + return array_merge( | |
| 139 | + $newArgs, | |
| 140 | + $args | |
| 141 | + ); | |
| 142 | + } | |
| 143 | 143 | } | 
| @@ -19,132 +19,132 @@ | ||
| 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 | - $newArgs = [ | |
| 76 | - 'datetime' => [ | |
| 77 | - 'type' => 'ID', | |
| 78 | - 'description' => esc_html__( | |
| 79 | - 'Globally unique datetime ID to get the attendees for.', | |
| 80 | - 'event_espresso' | |
| 81 | - ), | |
| 82 | - ], | |
| 83 | - 'datetimeIn' => [ | |
| 84 | - 'type' => ['list_of' => 'ID'], | |
| 85 | - 'description' => esc_html__( | |
| 86 | - 'Globally unique datetime IDs to get the attendees for.', | |
| 87 | - 'event_espresso' | |
| 88 | - ), | |
| 89 | - ], | |
| 90 | - 'event' => [ | |
| 91 | - 'type' => 'ID', | |
| 92 | - 'description' => esc_html__( | |
| 93 | - 'Globally unique event ID to get the attendees for.', | |
| 94 | - 'event_espresso' | |
| 95 | - ), | |
| 96 | - ], | |
| 97 | - 'eventIn' => [ | |
| 98 | - 'type' => ['list_of' => 'ID'], | |
| 99 | - 'description' => esc_html__( | |
| 100 | - 'Globally unique event IDs to get the attendees for.', | |
| 101 | - 'event_espresso' | |
| 102 | - ), | |
| 103 | - ], | |
| 104 | - 'orderby' => [ | |
| 105 | - 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], | |
| 106 | -                'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 107 | - ], | |
| 108 | - 'regTicket' => [ | |
| 109 | - 'type' => 'ID', | |
| 110 | - 'description' => esc_html__( | |
| 111 | - 'Globally unique registration ticket ID to get the attendees for.', | |
| 112 | - 'event_espresso' | |
| 113 | - ), | |
| 114 | - ], | |
| 115 | - 'regTicketIn' => [ | |
| 116 | - 'type' => ['list_of' => 'ID'], | |
| 117 | - 'description' => esc_html__( | |
| 118 | - 'Globally unique registration ticket IDs to get the attendees for.', | |
| 119 | - 'event_espresso' | |
| 120 | - ), | |
| 121 | - ], | |
| 122 | - 'regTicketId' => [ | |
| 123 | - 'type' => 'Int', | |
| 124 | -                'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), | |
| 125 | - ], | |
| 126 | - 'regTicketIdIn' => [ | |
| 127 | - 'type' => ['list_of' => 'Int'], | |
| 128 | -                'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), | |
| 129 | - ], | |
| 130 | - 'regStatus' => [ | |
| 131 | - 'type' => 'EspressoRegistrationStatusEnum', | |
| 132 | -                'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), | |
| 133 | - ], | |
| 134 | - 'search' => [ | |
| 135 | - 'type' => 'String', | |
| 136 | -                'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 137 | - ], | |
| 138 | - ]; | |
| 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 | + $newArgs = [ | |
| 76 | + 'datetime' => [ | |
| 77 | + 'type' => 'ID', | |
| 78 | + 'description' => esc_html__( | |
| 79 | + 'Globally unique datetime ID to get the attendees for.', | |
| 80 | + 'event_espresso' | |
| 81 | + ), | |
| 82 | + ], | |
| 83 | + 'datetimeIn' => [ | |
| 84 | + 'type' => ['list_of' => 'ID'], | |
| 85 | + 'description' => esc_html__( | |
| 86 | + 'Globally unique datetime IDs to get the attendees for.', | |
| 87 | + 'event_espresso' | |
| 88 | + ), | |
| 89 | + ], | |
| 90 | + 'event' => [ | |
| 91 | + 'type' => 'ID', | |
| 92 | + 'description' => esc_html__( | |
| 93 | + 'Globally unique event ID to get the attendees for.', | |
| 94 | + 'event_espresso' | |
| 95 | + ), | |
| 96 | + ], | |
| 97 | + 'eventIn' => [ | |
| 98 | + 'type' => ['list_of' => 'ID'], | |
| 99 | + 'description' => esc_html__( | |
| 100 | + 'Globally unique event IDs to get the attendees for.', | |
| 101 | + 'event_espresso' | |
| 102 | + ), | |
| 103 | + ], | |
| 104 | + 'orderby' => [ | |
| 105 | + 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], | |
| 106 | +				'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), | |
| 107 | + ], | |
| 108 | + 'regTicket' => [ | |
| 109 | + 'type' => 'ID', | |
| 110 | + 'description' => esc_html__( | |
| 111 | + 'Globally unique registration ticket ID to get the attendees for.', | |
| 112 | + 'event_espresso' | |
| 113 | + ), | |
| 114 | + ], | |
| 115 | + 'regTicketIn' => [ | |
| 116 | + 'type' => ['list_of' => 'ID'], | |
| 117 | + 'description' => esc_html__( | |
| 118 | + 'Globally unique registration ticket IDs to get the attendees for.', | |
| 119 | + 'event_espresso' | |
| 120 | + ), | |
| 121 | + ], | |
| 122 | + 'regTicketId' => [ | |
| 123 | + 'type' => 'Int', | |
| 124 | +				'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), | |
| 125 | + ], | |
| 126 | + 'regTicketIdIn' => [ | |
| 127 | + 'type' => ['list_of' => 'Int'], | |
| 128 | +				'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), | |
| 129 | + ], | |
| 130 | + 'regStatus' => [ | |
| 131 | + 'type' => 'EspressoRegistrationStatusEnum', | |
| 132 | +				'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), | |
| 133 | + ], | |
| 134 | + 'search' => [ | |
| 135 | + 'type' => 'String', | |
| 136 | +				'description' => esc_html__('The search keywords', 'event_espresso'), | |
| 137 | + ], | |
| 138 | + ]; | |
| 139 | 139 | |
| 140 | - $newArgs = apply_filters( | |
| 141 | - 'FHEE__EventEspresso_core_domain_services_graphql_connections__attendee_args', | |
| 142 | - $newArgs, | |
| 143 | - $args | |
| 144 | - ); | |
| 145 | - return array_merge( | |
| 146 | - $newArgs, | |
| 147 | - $args | |
| 148 | - ); | |
| 149 | - } | |
| 140 | + $newArgs = apply_filters( | |
| 141 | + 'FHEE__EventEspresso_core_domain_services_graphql_connections__attendee_args', | |
| 142 | + $newArgs, | |
| 143 | + $args | |
| 144 | + ); | |
| 145 | + return array_merge( | |
| 146 | + $newArgs, | |
| 147 | + $args | |
| 148 | + ); | |
| 149 | + } | |
| 150 | 150 | } | 
| @@ -20,169 +20,169 @@ | ||
| 20 | 20 |  { | 
| 21 | 21 | |
| 22 | 22 | |
| 23 | - /** | |
| 24 | - * @var Utilities | |
| 25 | - */ | |
| 26 | - private $utilities; | |
| 27 | - | |
| 28 | - | |
| 29 | - /** | |
| 30 | - * @return Utilities | |
| 31 | - */ | |
| 32 | - public function getUtilities() | |
| 33 | -    { | |
| 34 | -        if (! $this->utilities instanceof Utilities) { | |
| 35 | - $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); | |
| 36 | - } | |
| 37 | - return $this->utilities; | |
| 38 | - } | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Determine whether the Query should execute. If it's determined that the query should | |
| 42 | - * not be run based on context such as, but not limited to, who the user is, where in the | |
| 43 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc | |
| 44 | - * Return false to prevent the query from executing. | |
| 45 | - * | |
| 46 | - * @return bool | |
| 47 | - */ | |
| 48 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 49 | - public function should_execute() | |
| 50 | -    { | |
| 51 | - return $this->should_execute; | |
| 52 | - } | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Set limit the highest value of first and last, with a (filterable) max of 100 | |
| 56 | - * | |
| 57 | - * @return array | |
| 58 | - */ | |
| 59 | - protected function getLimit() | |
| 60 | -    { | |
| 61 | - $first = ! empty($this->args['first']) ? absint($this->args['first']) : null; | |
| 62 | - $last = ! empty($this->args['last']) ? absint($this->args['last']) : null; | |
| 63 | - | |
| 64 | - $limit = min( | |
| 65 | - max($first, $last, 100), | |
| 66 | - $this->query_amount | |
| 67 | - ); | |
| 68 | - $limit++; | |
| 69 | - return $limit; | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * Get_amount_requested | |
| 74 | - * | |
| 75 | - * This checks the $args to determine the amount requested | |
| 76 | - * | |
| 77 | - * @return int|null | |
| 78 | - * @throws Exception | |
| 79 | - */ | |
| 80 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 81 | - public function get_amount_requested() | |
| 82 | -    { | |
| 83 | - $amount_requested = parent::get_amount_requested(); | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * If both first & last are used in the input args, throw an exception as that won't | |
| 87 | - * work properly | |
| 88 | - */ | |
| 89 | -        if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === 10) { | |
| 90 | - return 100; // default. | |
| 91 | - } | |
| 92 | - | |
| 93 | - return $amount_requested; | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * Determine whether or not the the offset is valid, i.e the entity corresponding to the | |
| 98 | - * offset exists. Offset is equivalent to entity ID. So this function is equivalent to | |
| 99 | - * checking if the entity with the given ID exists. | |
| 100 | - * | |
| 101 | - * @access public | |
| 102 | - * | |
| 103 | - * @param int $offset The ID of the node used for the cursor offset | |
| 104 | - * | |
| 105 | - * @return bool | |
| 106 | - */ | |
| 107 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 108 | - public function is_valid_offset($offset) | |
| 109 | -    { | |
| 110 | - $entity = $this->get_query()->get_one_by_ID($offset); | |
| 23 | + /** | |
| 24 | + * @var Utilities | |
| 25 | + */ | |
| 26 | + private $utilities; | |
| 27 | + | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @return Utilities | |
| 31 | + */ | |
| 32 | + public function getUtilities() | |
| 33 | +	{ | |
| 34 | +		if (! $this->utilities instanceof Utilities) { | |
| 35 | + $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); | |
| 36 | + } | |
| 37 | + return $this->utilities; | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Determine whether the Query should execute. If it's determined that the query should | |
| 42 | + * not be run based on context such as, but not limited to, who the user is, where in the | |
| 43 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc | |
| 44 | + * Return false to prevent the query from executing. | |
| 45 | + * | |
| 46 | + * @return bool | |
| 47 | + */ | |
| 48 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 49 | + public function should_execute() | |
| 50 | +	{ | |
| 51 | + return $this->should_execute; | |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Set limit the highest value of first and last, with a (filterable) max of 100 | |
| 56 | + * | |
| 57 | + * @return array | |
| 58 | + */ | |
| 59 | + protected function getLimit() | |
| 60 | +	{ | |
| 61 | + $first = ! empty($this->args['first']) ? absint($this->args['first']) : null; | |
| 62 | + $last = ! empty($this->args['last']) ? absint($this->args['last']) : null; | |
| 63 | + | |
| 64 | + $limit = min( | |
| 65 | + max($first, $last, 100), | |
| 66 | + $this->query_amount | |
| 67 | + ); | |
| 68 | + $limit++; | |
| 69 | + return $limit; | |
| 70 | + } | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * Get_amount_requested | |
| 74 | + * | |
| 75 | + * This checks the $args to determine the amount requested | |
| 76 | + * | |
| 77 | + * @return int|null | |
| 78 | + * @throws Exception | |
| 79 | + */ | |
| 80 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 81 | + public function get_amount_requested() | |
| 82 | +	{ | |
| 83 | + $amount_requested = parent::get_amount_requested(); | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * If both first & last are used in the input args, throw an exception as that won't | |
| 87 | + * work properly | |
| 88 | + */ | |
| 89 | +		if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === 10) { | |
| 90 | + return 100; // default. | |
| 91 | + } | |
| 92 | + | |
| 93 | + return $amount_requested; | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Determine whether or not the the offset is valid, i.e the entity corresponding to the | |
| 98 | + * offset exists. Offset is equivalent to entity ID. So this function is equivalent to | |
| 99 | + * checking if the entity with the given ID exists. | |
| 100 | + * | |
| 101 | + * @access public | |
| 102 | + * | |
| 103 | + * @param int $offset The ID of the node used for the cursor offset | |
| 104 | + * | |
| 105 | + * @return bool | |
| 106 | + */ | |
| 107 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 108 | + public function is_valid_offset($offset) | |
| 109 | +	{ | |
| 110 | + $entity = $this->get_query()->get_one_by_ID($offset); | |
| 111 | 111 | |
| 112 | - return $entity instanceof EE_Base_Class; | |
| 113 | - } | |
| 114 | - | |
| 115 | - /** | |
| 116 | - * Validates Model. | |
| 117 | - * | |
| 118 | - * @param array $entity Entity node. | |
| 119 | - * | |
| 120 | - * @return bool | |
| 121 | - */ | |
| 122 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 123 | - protected function is_valid_model($entity) | |
| 124 | -    { | |
| 125 | - return $entity instanceof EE_Base_Class; | |
| 126 | - } | |
| 127 | - | |
| 128 | - | |
| 129 | - /** | |
| 130 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 131 | - * friendly keys. | |
| 132 | - * | |
| 133 | - * @param array $query_args | |
| 134 | - * @param array $where_params | |
| 135 | - * @param string $primary_key | |
| 136 | - * @return array | |
| 137 | - */ | |
| 138 | - protected function mapOrderbyInputArgs(array $query_args, array $where_params, $primary_key) | |
| 139 | -    { | |
| 140 | - // ID of the current offset | |
| 141 | - $offset = $this->get_offset(); | |
| 142 | - /** | |
| 143 | - * Map the orderby inputArgs to the WP_Query | |
| 144 | - */ | |
| 145 | -        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { | |
| 146 | - $query_args['order_by'] = []; | |
| 147 | -            foreach ($this->args['where']['orderby'] as $orderby_input) { | |
| 148 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; | |
| 149 | - } | |
| 150 | -        } elseif ($offset) { | |
| 151 | - $compare = $this->args['last'] ? '<' : '>'; | |
| 152 | - $where_params[ $primary_key ] = [ $compare, $offset ]; | |
| 153 | - } | |
| 154 | - return [ $query_args, $where_params ]; | |
| 155 | - } | |
| 156 | - | |
| 157 | - | |
| 158 | - /** | |
| 159 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 160 | - * friendly keys. | |
| 161 | - * | |
| 162 | - * @param array $where_args | |
| 163 | - * @param array $arg_mapping | |
| 164 | - * @param array $id_fields The fields to convert from global IDs to DB IDs. | |
| 165 | - * @return array | |
| 166 | - */ | |
| 167 | - protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields) | |
| 168 | -    { | |
| 169 | - $query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields); | |
| 170 | - return ! empty($query_args) && is_array($query_args) ? $query_args : []; | |
| 171 | - } | |
| 172 | - | |
| 173 | - | |
| 174 | - /** | |
| 175 | - * This returns the sanitized "search" keywords from where_args | |
| 176 | - * | |
| 177 | - * @param array $where_args | |
| 178 | - * @return string | |
| 179 | - */ | |
| 180 | - protected function getSearchKeywords(array $where_args) | |
| 181 | -    { | |
| 182 | - $search = ''; | |
| 183 | -        if (! empty($where_args['search'])) { | |
| 184 | - $search = sanitize_text_field($where_args['search']); | |
| 185 | - } | |
| 186 | - return esc_sql($search); | |
| 187 | - } | |
| 112 | + return $entity instanceof EE_Base_Class; | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * Validates Model. | |
| 117 | + * | |
| 118 | + * @param array $entity Entity node. | |
| 119 | + * | |
| 120 | + * @return bool | |
| 121 | + */ | |
| 122 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 123 | + protected function is_valid_model($entity) | |
| 124 | +	{ | |
| 125 | + return $entity instanceof EE_Base_Class; | |
| 126 | + } | |
| 127 | + | |
| 128 | + | |
| 129 | + /** | |
| 130 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 131 | + * friendly keys. | |
| 132 | + * | |
| 133 | + * @param array $query_args | |
| 134 | + * @param array $where_params | |
| 135 | + * @param string $primary_key | |
| 136 | + * @return array | |
| 137 | + */ | |
| 138 | + protected function mapOrderbyInputArgs(array $query_args, array $where_params, $primary_key) | |
| 139 | +	{ | |
| 140 | + // ID of the current offset | |
| 141 | + $offset = $this->get_offset(); | |
| 142 | + /** | |
| 143 | + * Map the orderby inputArgs to the WP_Query | |
| 144 | + */ | |
| 145 | +		if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { | |
| 146 | + $query_args['order_by'] = []; | |
| 147 | +			foreach ($this->args['where']['orderby'] as $orderby_input) { | |
| 148 | + $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; | |
| 149 | + } | |
| 150 | +		} elseif ($offset) { | |
| 151 | + $compare = $this->args['last'] ? '<' : '>'; | |
| 152 | + $where_params[ $primary_key ] = [ $compare, $offset ]; | |
| 153 | + } | |
| 154 | + return [ $query_args, $where_params ]; | |
| 155 | + } | |
| 156 | + | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 160 | + * friendly keys. | |
| 161 | + * | |
| 162 | + * @param array $where_args | |
| 163 | + * @param array $arg_mapping | |
| 164 | + * @param array $id_fields The fields to convert from global IDs to DB IDs. | |
| 165 | + * @return array | |
| 166 | + */ | |
| 167 | + protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields) | |
| 168 | +	{ | |
| 169 | + $query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields); | |
| 170 | + return ! empty($query_args) && is_array($query_args) ? $query_args : []; | |
| 171 | + } | |
| 172 | + | |
| 173 | + | |
| 174 | + /** | |
| 175 | + * This returns the sanitized "search" keywords from where_args | |
| 176 | + * | |
| 177 | + * @param array $where_args | |
| 178 | + * @return string | |
| 179 | + */ | |
| 180 | + protected function getSearchKeywords(array $where_args) | |
| 181 | +	{ | |
| 182 | + $search = ''; | |
| 183 | +		if (! empty($where_args['search'])) { | |
| 184 | + $search = sanitize_text_field($where_args['search']); | |
| 185 | + } | |
| 186 | + return esc_sql($search); | |
| 187 | + } | |
| 188 | 188 | } | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | */ | 
| 32 | 32 | public function getUtilities() | 
| 33 | 33 |      { | 
| 34 | -        if (! $this->utilities instanceof Utilities) { | |
| 34 | +        if ( ! $this->utilities instanceof Utilities) { | |
| 35 | 35 | $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); | 
| 36 | 36 | } | 
| 37 | 37 | return $this->utilities; | 
| @@ -142,16 +142,16 @@ discard block | ||
| 142 | 142 | /** | 
| 143 | 143 | * Map the orderby inputArgs to the WP_Query | 
| 144 | 144 | */ | 
| 145 | -        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { | |
| 145 | +        if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { | |
| 146 | 146 | $query_args['order_by'] = []; | 
| 147 | 147 |              foreach ($this->args['where']['orderby'] as $orderby_input) { | 
| 148 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; | |
| 148 | + $query_args['order_by'][$orderby_input['field']] = $orderby_input['order']; | |
| 149 | 149 | } | 
| 150 | 150 |          } elseif ($offset) { | 
| 151 | 151 | $compare = $this->args['last'] ? '<' : '>'; | 
| 152 | - $where_params[ $primary_key ] = [ $compare, $offset ]; | |
| 152 | + $where_params[$primary_key] = [$compare, $offset]; | |
| 153 | 153 | } | 
| 154 | - return [ $query_args, $where_params ]; | |
| 154 | + return [$query_args, $where_params]; | |
| 155 | 155 | } | 
| 156 | 156 | |
| 157 | 157 | |
| @@ -180,7 +180,7 @@ discard block | ||
| 180 | 180 | protected function getSearchKeywords(array $where_args) | 
| 181 | 181 |      { | 
| 182 | 182 | $search = ''; | 
| 183 | -        if (! empty($where_args['search'])) { | |
| 183 | +        if ( ! empty($where_args['search'])) { | |
| 184 | 184 | $search = sanitize_text_field($where_args['search']); | 
| 185 | 185 | } | 
| 186 | 186 | return esc_sql($search); | 
| @@ -16,178 +16,178 @@ | ||
| 16 | 16 | */ | 
| 17 | 17 | class AttendeeConnectionResolver extends AbstractConnectionResolver | 
| 18 | 18 |  { | 
| 19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 20 | - public function get_loader_name() | |
| 21 | -    { | |
| 22 | - return 'espresso_attendee'; | |
| 23 | - } | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * @return EEM_Attendee | |
| 27 | - * @throws EE_Error | |
| 28 | - * @throws InvalidArgumentException | |
| 29 | - * @throws InvalidDataTypeException | |
| 30 | - * @throws InvalidInterfaceException | |
| 31 | - */ | |
| 32 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 33 | - public function get_query() | |
| 34 | -    { | |
| 35 | - return EEM_Attendee::instance(); | |
| 36 | - } | |
| 37 | - | |
| 38 | - | |
| 39 | - /** | |
| 40 | - * Return an array of item IDs from the query | |
| 41 | - * | |
| 42 | - * @return array | |
| 43 | - */ | |
| 44 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 45 | - public function get_ids() | |
| 46 | -    { | |
| 47 | - $results = $this->query->get_col($this->query_args); | |
| 48 | - | |
| 49 | - return ! empty($results) ? $results : []; | |
| 50 | - } | |
| 51 | - | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Here, we map the args from the input, then we make sure that we're only querying | |
| 55 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 56 | - * handle batch resolution of the posts. | |
| 57 | - * | |
| 58 | - * @return array | |
| 59 | - * @throws EE_Error | |
| 60 | - * @throws InvalidArgumentException | |
| 61 | - * @throws ReflectionException | |
| 62 | - * @throws InvalidDataTypeException | |
| 63 | - * @throws InvalidInterfaceException | |
| 64 | - */ | |
| 65 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 66 | - public function get_query_args() | |
| 67 | -    { | |
| 68 | - $where_params = []; | |
| 69 | - $query_args = []; | |
| 70 | - | |
| 71 | - $query_args['limit'] = $this->getLimit(); | |
| 72 | - | |
| 73 | - // Avoid multiple entries by join. | |
| 74 | - $query_args['group_by'] = 'ATT_ID'; | |
| 75 | - | |
| 76 | - $query_args['default_where_conditions'] = 'minimum'; | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 80 | - */ | |
| 81 | - $input_fields = []; | |
| 82 | -        if (! empty($this->args['where'])) { | |
| 83 | - $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 84 | - | |
| 85 | - // Since we do not have any falsy values in query params | |
| 86 | - // Lets get rid of empty values | |
| 87 | - $input_fields = array_filter($input_fields); | |
| 88 | - | |
| 89 | - // Use the proper operator. | |
| 90 | -            if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { | |
| 91 | - $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; | |
| 92 | - } | |
| 93 | -            if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 94 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; | |
| 95 | - } | |
| 96 | - // If Ticket param is passed, it will have preference over Datetime param | |
| 97 | - // So, use Datetime param only if a Ticket param is not passed | |
| 98 | -            if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 99 | - $datetimeIds = $input_fields['Datetime.DTT_ID']; | |
| 100 | - // Make sure it's an array, ready for "IN" operator | |
| 101 | - $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; | |
| 102 | - | |
| 103 | -                try { | |
| 104 | - // Get related ticket IDs for the given dates | |
| 105 | - $ticketIds = EEM_Ticket::instance()->get_col([ | |
| 106 | - [ | |
| 107 | - 'Datetime.DTT_ID' => ['IN', $datetimeIds], | |
| 108 | - 'TKT_deleted' => ['IN', [true, false]], | |
| 109 | - ], | |
| 110 | - 'default_where_conditions' => 'minimum', | |
| 111 | - ]); | |
| 112 | -                } catch (Throwable $th) { | |
| 113 | - $ticketIds = []; | |
| 114 | - } | |
| 115 | - | |
| 116 | -                if (!empty($ticketIds)) { | |
| 117 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; | |
| 118 | - } | |
| 119 | - } | |
| 120 | - // Since there is no relation between Attendee and Datetime, we need to remove it | |
| 121 | - unset($input_fields['Datetime.DTT_ID']); | |
| 122 | - } | |
| 123 | - | |
| 124 | - /** | |
| 125 | - * Merge the input_fields with the default query_args | |
| 126 | - */ | |
| 127 | -        if (! empty($input_fields)) { | |
| 128 | - $where_params = array_merge($where_params, $input_fields); | |
| 129 | - } | |
| 130 | - | |
| 131 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); | |
| 132 | - | |
| 133 | - $search = $this->getSearchKeywords($this->args['where']); | |
| 134 | - | |
| 135 | -        if (! empty($search)) { | |
| 136 | - // use OR operator to search in any of the fields | |
| 137 | - $where_params['OR'] = array( | |
| 138 | -                'ATT_full_name' => array('LIKE', '%' . $search . '%'), | |
| 139 | -                'ATT_bio'       => array('LIKE', '%' . $search . '%'), | |
| 140 | -                'ATT_short_bio' => array('LIKE', '%' . $search . '%'), | |
| 141 | - ); | |
| 142 | - } | |
| 143 | - | |
| 144 | - $where_params = apply_filters( | |
| 145 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_where_params', | |
| 146 | - $where_params, | |
| 147 | - $this->source, | |
| 148 | - $this->args | |
| 149 | - ); | |
| 150 | - | |
| 151 | - $query_args[] = $where_params; | |
| 152 | - | |
| 153 | - /** | |
| 154 | - * Return the $query_args | |
| 155 | - */ | |
| 156 | - return apply_filters( | |
| 157 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_query_args', | |
| 158 | - $query_args, | |
| 159 | - $this->source, | |
| 160 | - $this->args | |
| 161 | - ); | |
| 162 | - } | |
| 163 | - | |
| 164 | - | |
| 165 | - /** | |
| 166 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 167 | - * friendly keys. | |
| 168 | - * | |
| 169 | - * @param array $where_args | |
| 170 | - * @return array | |
| 171 | - */ | |
| 172 | - public function sanitizeInputFields(array $where_args) | |
| 173 | -    { | |
| 174 | - $arg_mapping = [ | |
| 175 | - // There is no direct relation between Attendee and Datetime | |
| 176 | - // But we will handle it via Tickets related to given dates | |
| 177 | - 'datetime' => 'Datetime.DTT_ID', | |
| 178 | - 'datetimeIn' => 'Datetime.DTT_ID', | |
| 179 | - 'event' => 'Registration.Event.EVT_ID', | |
| 180 | - 'eventIn' => 'Registration.Event.EVT_ID', | |
| 181 | - 'regTicket' => 'Registration.Ticket.TKT_ID', | |
| 182 | - 'regTicketIn' => 'Registration.Ticket.TKT_ID', | |
| 183 | - 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', | |
| 184 | - 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. | |
| 185 | - 'regStatus' => 'Registration.Status.STS_ID', | |
| 186 | - ]; | |
| 187 | - return $this->sanitizeWhereArgsForInputFields( | |
| 188 | - $where_args, | |
| 189 | - $arg_mapping, | |
| 190 | - ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] | |
| 191 | - ); | |
| 192 | - } | |
| 19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 20 | + public function get_loader_name() | |
| 21 | +	{ | |
| 22 | + return 'espresso_attendee'; | |
| 23 | + } | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * @return EEM_Attendee | |
| 27 | + * @throws EE_Error | |
| 28 | + * @throws InvalidArgumentException | |
| 29 | + * @throws InvalidDataTypeException | |
| 30 | + * @throws InvalidInterfaceException | |
| 31 | + */ | |
| 32 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 33 | + public function get_query() | |
| 34 | +	{ | |
| 35 | + return EEM_Attendee::instance(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * Return an array of item IDs from the query | |
| 41 | + * | |
| 42 | + * @return array | |
| 43 | + */ | |
| 44 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 45 | + public function get_ids() | |
| 46 | +	{ | |
| 47 | + $results = $this->query->get_col($this->query_args); | |
| 48 | + | |
| 49 | + return ! empty($results) ? $results : []; | |
| 50 | + } | |
| 51 | + | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Here, we map the args from the input, then we make sure that we're only querying | |
| 55 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 56 | + * handle batch resolution of the posts. | |
| 57 | + * | |
| 58 | + * @return array | |
| 59 | + * @throws EE_Error | |
| 60 | + * @throws InvalidArgumentException | |
| 61 | + * @throws ReflectionException | |
| 62 | + * @throws InvalidDataTypeException | |
| 63 | + * @throws InvalidInterfaceException | |
| 64 | + */ | |
| 65 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 66 | + public function get_query_args() | |
| 67 | +	{ | |
| 68 | + $where_params = []; | |
| 69 | + $query_args = []; | |
| 70 | + | |
| 71 | + $query_args['limit'] = $this->getLimit(); | |
| 72 | + | |
| 73 | + // Avoid multiple entries by join. | |
| 74 | + $query_args['group_by'] = 'ATT_ID'; | |
| 75 | + | |
| 76 | + $query_args['default_where_conditions'] = 'minimum'; | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 80 | + */ | |
| 81 | + $input_fields = []; | |
| 82 | +		if (! empty($this->args['where'])) { | |
| 83 | + $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 84 | + | |
| 85 | + // Since we do not have any falsy values in query params | |
| 86 | + // Lets get rid of empty values | |
| 87 | + $input_fields = array_filter($input_fields); | |
| 88 | + | |
| 89 | + // Use the proper operator. | |
| 90 | +			if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { | |
| 91 | + $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; | |
| 92 | + } | |
| 93 | +			if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 94 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; | |
| 95 | + } | |
| 96 | + // If Ticket param is passed, it will have preference over Datetime param | |
| 97 | + // So, use Datetime param only if a Ticket param is not passed | |
| 98 | +			if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 99 | + $datetimeIds = $input_fields['Datetime.DTT_ID']; | |
| 100 | + // Make sure it's an array, ready for "IN" operator | |
| 101 | + $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; | |
| 102 | + | |
| 103 | +				try { | |
| 104 | + // Get related ticket IDs for the given dates | |
| 105 | + $ticketIds = EEM_Ticket::instance()->get_col([ | |
| 106 | + [ | |
| 107 | + 'Datetime.DTT_ID' => ['IN', $datetimeIds], | |
| 108 | + 'TKT_deleted' => ['IN', [true, false]], | |
| 109 | + ], | |
| 110 | + 'default_where_conditions' => 'minimum', | |
| 111 | + ]); | |
| 112 | +				} catch (Throwable $th) { | |
| 113 | + $ticketIds = []; | |
| 114 | + } | |
| 115 | + | |
| 116 | +				if (!empty($ticketIds)) { | |
| 117 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; | |
| 118 | + } | |
| 119 | + } | |
| 120 | + // Since there is no relation between Attendee and Datetime, we need to remove it | |
| 121 | + unset($input_fields['Datetime.DTT_ID']); | |
| 122 | + } | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Merge the input_fields with the default query_args | |
| 126 | + */ | |
| 127 | +		if (! empty($input_fields)) { | |
| 128 | + $where_params = array_merge($where_params, $input_fields); | |
| 129 | + } | |
| 130 | + | |
| 131 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); | |
| 132 | + | |
| 133 | + $search = $this->getSearchKeywords($this->args['where']); | |
| 134 | + | |
| 135 | +		if (! empty($search)) { | |
| 136 | + // use OR operator to search in any of the fields | |
| 137 | + $where_params['OR'] = array( | |
| 138 | +				'ATT_full_name' => array('LIKE', '%' . $search . '%'), | |
| 139 | +				'ATT_bio'       => array('LIKE', '%' . $search . '%'), | |
| 140 | +				'ATT_short_bio' => array('LIKE', '%' . $search . '%'), | |
| 141 | + ); | |
| 142 | + } | |
| 143 | + | |
| 144 | + $where_params = apply_filters( | |
| 145 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_where_params', | |
| 146 | + $where_params, | |
| 147 | + $this->source, | |
| 148 | + $this->args | |
| 149 | + ); | |
| 150 | + | |
| 151 | + $query_args[] = $where_params; | |
| 152 | + | |
| 153 | + /** | |
| 154 | + * Return the $query_args | |
| 155 | + */ | |
| 156 | + return apply_filters( | |
| 157 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_query_args', | |
| 158 | + $query_args, | |
| 159 | + $this->source, | |
| 160 | + $this->args | |
| 161 | + ); | |
| 162 | + } | |
| 163 | + | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 167 | + * friendly keys. | |
| 168 | + * | |
| 169 | + * @param array $where_args | |
| 170 | + * @return array | |
| 171 | + */ | |
| 172 | + public function sanitizeInputFields(array $where_args) | |
| 173 | +	{ | |
| 174 | + $arg_mapping = [ | |
| 175 | + // There is no direct relation between Attendee and Datetime | |
| 176 | + // But we will handle it via Tickets related to given dates | |
| 177 | + 'datetime' => 'Datetime.DTT_ID', | |
| 178 | + 'datetimeIn' => 'Datetime.DTT_ID', | |
| 179 | + 'event' => 'Registration.Event.EVT_ID', | |
| 180 | + 'eventIn' => 'Registration.Event.EVT_ID', | |
| 181 | + 'regTicket' => 'Registration.Ticket.TKT_ID', | |
| 182 | + 'regTicketIn' => 'Registration.Ticket.TKT_ID', | |
| 183 | + 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', | |
| 184 | + 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. | |
| 185 | + 'regStatus' => 'Registration.Status.STS_ID', | |
| 186 | + ]; | |
| 187 | + return $this->sanitizeWhereArgsForInputFields( | |
| 188 | + $where_args, | |
| 189 | + $arg_mapping, | |
| 190 | + ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] | |
| 191 | + ); | |
| 192 | + } | |
| 193 | 193 | } | 
| @@ -79,7 +79,7 @@ discard block | ||
| 79 | 79 | * Collect the input_fields and sanitize them to prepare them for sending to the Query | 
| 80 | 80 | */ | 
| 81 | 81 | $input_fields = []; | 
| 82 | -        if (! empty($this->args['where'])) { | |
| 82 | +        if ( ! empty($this->args['where'])) { | |
| 83 | 83 | $input_fields = $this->sanitizeInputFields($this->args['where']); | 
| 84 | 84 | |
| 85 | 85 | // Since we do not have any falsy values in query params | 
| @@ -87,15 +87,15 @@ discard block | ||
| 87 | 87 | $input_fields = array_filter($input_fields); | 
| 88 | 88 | |
| 89 | 89 | // Use the proper operator. | 
| 90 | -            if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { | |
| 90 | +            if ( ! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { | |
| 91 | 91 | $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; | 
| 92 | 92 | } | 
| 93 | -            if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 93 | +            if ( ! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 94 | 94 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; | 
| 95 | 95 | } | 
| 96 | 96 | // If Ticket param is passed, it will have preference over Datetime param | 
| 97 | 97 | // So, use Datetime param only if a Ticket param is not passed | 
| 98 | -            if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 98 | +            if ( ! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { | |
| 99 | 99 | $datetimeIds = $input_fields['Datetime.DTT_ID']; | 
| 100 | 100 | // Make sure it's an array, ready for "IN" operator | 
| 101 | 101 | $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | $ticketIds = []; | 
| 114 | 114 | } | 
| 115 | 115 | |
| 116 | -                if (!empty($ticketIds)) { | |
| 116 | +                if ( ! empty($ticketIds)) { | |
| 117 | 117 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; | 
| 118 | 118 | } | 
| 119 | 119 | } | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | /** | 
| 125 | 125 | * Merge the input_fields with the default query_args | 
| 126 | 126 | */ | 
| 127 | -        if (! empty($input_fields)) { | |
| 127 | +        if ( ! empty($input_fields)) { | |
| 128 | 128 | $where_params = array_merge($where_params, $input_fields); | 
| 129 | 129 | } | 
| 130 | 130 | |
| @@ -132,12 +132,12 @@ discard block | ||
| 132 | 132 | |
| 133 | 133 | $search = $this->getSearchKeywords($this->args['where']); | 
| 134 | 134 | |
| 135 | -        if (! empty($search)) { | |
| 135 | +        if ( ! empty($search)) { | |
| 136 | 136 | // use OR operator to search in any of the fields | 
| 137 | 137 | $where_params['OR'] = array( | 
| 138 | -                'ATT_full_name' => array('LIKE', '%' . $search . '%'), | |
| 139 | -                'ATT_bio'       => array('LIKE', '%' . $search . '%'), | |
| 140 | -                'ATT_short_bio' => array('LIKE', '%' . $search . '%'), | |
| 138 | +                'ATT_full_name' => array('LIKE', '%'.$search.'%'), | |
| 139 | +                'ATT_bio'       => array('LIKE', '%'.$search.'%'), | |
| 140 | +                'ATT_short_bio' => array('LIKE', '%'.$search.'%'), | |
| 141 | 141 | ); | 
| 142 | 142 | } | 
| 143 | 143 | |
| @@ -18,191 +18,191 @@ | ||
| 18 | 18 | */ | 
| 19 | 19 | class DatetimeConnectionResolver extends AbstractConnectionResolver | 
| 20 | 20 |  { | 
| 21 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 22 | - public function get_loader_name() | |
| 23 | -    { | |
| 24 | - return 'espresso_datetime'; | |
| 25 | - } | |
| 26 | - | |
| 27 | - /** | |
| 28 | - * @return EEM_Datetime | |
| 29 | - * @throws EE_Error | |
| 30 | - * @throws InvalidArgumentException | |
| 31 | - * @throws InvalidDataTypeException | |
| 32 | - * @throws InvalidInterfaceException | |
| 33 | - */ | |
| 34 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 35 | - public function get_query() | |
| 36 | -    { | |
| 37 | - return EEM_Datetime::instance(); | |
| 38 | - } | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Return an array of item IDs from the query | |
| 42 | - * | |
| 43 | - * @return array | |
| 44 | - */ | |
| 45 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 46 | - public function get_ids() | |
| 47 | -    { | |
| 48 | - $results = $this->query->get_col($this->query_args); | |
| 49 | - | |
| 50 | - return ! empty($results) ? $results : []; | |
| 51 | - } | |
| 52 | - | |
| 53 | - /** | |
| 54 | - * Here, we map the args from the input, then we make sure that we're only querying | |
| 55 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 56 | - * handle batch resolution of the posts. | |
| 57 | - * | |
| 58 | - * @return array | |
| 59 | - * @throws EE_Error | |
| 60 | - * @throws InvalidArgumentException | |
| 61 | - * @throws InvalidDataTypeException | |
| 62 | - * @throws InvalidInterfaceException | |
| 63 | - */ | |
| 64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 65 | - public function get_query_args() | |
| 66 | -    { | |
| 67 | - $where_params = ['DTT_deleted' => ['IN', [true, false]]]; | |
| 68 | - $query_args = []; | |
| 69 | - | |
| 70 | - $query_args['limit'] = $this->getLimit(); | |
| 71 | - | |
| 72 | - // Avoid multiple entries by join. | |
| 73 | - $query_args['group_by'] = 'DTT_ID'; | |
| 74 | - | |
| 75 | - $query_args['default_where_conditions'] = 'minimum'; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 79 | - */ | |
| 80 | - $input_fields = []; | |
| 81 | -        if (! empty($this->args['where'])) { | |
| 82 | - $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 83 | - | |
| 84 | - // Use the proper operator. | |
| 85 | -            if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { | |
| 86 | - $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; | |
| 87 | - } | |
| 88 | -            if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { | |
| 89 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; | |
| 90 | - } | |
| 91 | - } | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Determine where we're at in the Graph and adjust the query context appropriately. | |
| 95 | - * | |
| 96 | - * For example, if we're querying for datetime as a field of event query, this will automatically | |
| 97 | - * set the query to pull datetimes that belong to that event. | |
| 98 | - * We can set more cases for other source types. | |
| 99 | - */ | |
| 100 | -        if (is_object($this->source)) { | |
| 101 | -            switch (true) { | |
| 102 | - // It's surely an event | |
| 103 | - case $this->source instanceof Post: | |
| 104 | - $where_params['EVT_ID'] = $this->source->ID; | |
| 105 | - break; | |
| 106 | - case $this->source instanceof EE_Event: | |
| 107 | - $where_params['EVT_ID'] = $this->source->ID(); | |
| 108 | - break; | |
| 109 | - case $this->source instanceof EE_Ticket: | |
| 110 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); | |
| 111 | - break; | |
| 112 | - case $this->source instanceof EE_Checkin: | |
| 113 | - $where_params['Checkin.CHK_ID'] = $this->source->ID(); | |
| 114 | - break; | |
| 115 | - } | |
| 116 | - } | |
| 117 | - | |
| 118 | - /** | |
| 119 | - * Merge the input_fields with the default query_args | |
| 120 | - */ | |
| 121 | -        if (! empty($input_fields)) { | |
| 122 | - $where_params = array_merge($where_params, $input_fields); | |
| 123 | - } | |
| 124 | - | |
| 125 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); | |
| 126 | - | |
| 127 | - $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | |
| 128 | - | |
| 129 | -        if (! empty($search)) { | |
| 130 | - // use OR operator to search in any of the fields | |
| 131 | - $where_params['OR'] = array( | |
| 132 | -                'DTT_name'        => array('LIKE', '%' . $search . '%'), | |
| 133 | -                'DTT_description' => array('LIKE', '%' . $search . '%'), | |
| 134 | - ); | |
| 135 | - } | |
| 136 | - | |
| 137 | -        if (! empty($this->args['where']['upcoming'])) { | |
| 138 | - $where_params['DTT_EVT_start'] = array( | |
| 139 | - '>', | |
| 140 | -                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | |
| 141 | - ); | |
| 142 | - } | |
| 143 | - | |
| 144 | -        if (! empty($this->args['where']['active'])) { | |
| 145 | - $where_params['DTT_EVT_start'] = array( | |
| 146 | - '<', | |
| 147 | -                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | |
| 148 | - ); | |
| 149 | - $where_params['DTT_EVT_end'] = array( | |
| 150 | - '>', | |
| 151 | -                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') | |
| 152 | - ); | |
| 153 | - } | |
| 154 | - | |
| 155 | -        if (! empty($this->args['where']['expired'])) { | |
| 156 | - $where_params['DTT_EVT_end'] = array( | |
| 157 | - '<', | |
| 158 | -                EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') | |
| 159 | - ); | |
| 160 | - } | |
| 161 | - | |
| 162 | - $where_params = apply_filters( | |
| 163 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_where_params', | |
| 164 | - $where_params, | |
| 165 | - $this->source, | |
| 166 | - $this->args | |
| 167 | - ); | |
| 168 | - | |
| 169 | - $query_args[] = $where_params; | |
| 170 | - | |
| 171 | - /** | |
| 172 | - * Return the $query_args | |
| 173 | - */ | |
| 174 | - return apply_filters( | |
| 175 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_query_args', | |
| 176 | - $query_args, | |
| 177 | - $this->source, | |
| 178 | - $this->args | |
| 179 | - ); | |
| 180 | - } | |
| 181 | - | |
| 182 | - | |
| 183 | - /** | |
| 184 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 185 | - * friendly keys. | |
| 186 | - * | |
| 187 | - * @param array $where_args | |
| 188 | - * @return array | |
| 189 | - */ | |
| 190 | - public function sanitizeInputFields(array $where_args) | |
| 191 | -    { | |
| 192 | - $arg_mapping = [ | |
| 193 | - 'event' => 'EVT_ID', | |
| 194 | - 'eventIn' => 'EVT_ID', | |
| 195 | - 'eventId' => 'EVT_ID', | |
| 196 | - 'eventIdIn' => 'EVT_ID', | |
| 197 | - 'ticket' => 'Ticket.TKT_ID', | |
| 198 | - 'ticketIn' => 'Ticket.TKT_ID', | |
| 199 | - 'ticketId' => 'Ticket.TKT_ID', | |
| 200 | - 'ticketIdIn' => 'Ticket.TKT_ID', | |
| 201 | - ]; | |
| 202 | - return $this->sanitizeWhereArgsForInputFields( | |
| 203 | - $where_args, | |
| 204 | - $arg_mapping, | |
| 205 | - ['event', 'eventIn', 'ticket', 'ticketIn'] | |
| 206 | - ); | |
| 207 | - } | |
| 21 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 22 | + public function get_loader_name() | |
| 23 | +	{ | |
| 24 | + return 'espresso_datetime'; | |
| 25 | + } | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * @return EEM_Datetime | |
| 29 | + * @throws EE_Error | |
| 30 | + * @throws InvalidArgumentException | |
| 31 | + * @throws InvalidDataTypeException | |
| 32 | + * @throws InvalidInterfaceException | |
| 33 | + */ | |
| 34 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 35 | + public function get_query() | |
| 36 | +	{ | |
| 37 | + return EEM_Datetime::instance(); | |
| 38 | + } | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * Return an array of item IDs from the query | |
| 42 | + * | |
| 43 | + * @return array | |
| 44 | + */ | |
| 45 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 46 | + public function get_ids() | |
| 47 | +	{ | |
| 48 | + $results = $this->query->get_col($this->query_args); | |
| 49 | + | |
| 50 | + return ! empty($results) ? $results : []; | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Here, we map the args from the input, then we make sure that we're only querying | |
| 55 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 56 | + * handle batch resolution of the posts. | |
| 57 | + * | |
| 58 | + * @return array | |
| 59 | + * @throws EE_Error | |
| 60 | + * @throws InvalidArgumentException | |
| 61 | + * @throws InvalidDataTypeException | |
| 62 | + * @throws InvalidInterfaceException | |
| 63 | + */ | |
| 64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 65 | + public function get_query_args() | |
| 66 | +	{ | |
| 67 | + $where_params = ['DTT_deleted' => ['IN', [true, false]]]; | |
| 68 | + $query_args = []; | |
| 69 | + | |
| 70 | + $query_args['limit'] = $this->getLimit(); | |
| 71 | + | |
| 72 | + // Avoid multiple entries by join. | |
| 73 | + $query_args['group_by'] = 'DTT_ID'; | |
| 74 | + | |
| 75 | + $query_args['default_where_conditions'] = 'minimum'; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 79 | + */ | |
| 80 | + $input_fields = []; | |
| 81 | +		if (! empty($this->args['where'])) { | |
| 82 | + $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 83 | + | |
| 84 | + // Use the proper operator. | |
| 85 | +			if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { | |
| 86 | + $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; | |
| 87 | + } | |
| 88 | +			if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { | |
| 89 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Determine where we're at in the Graph and adjust the query context appropriately. | |
| 95 | + * | |
| 96 | + * For example, if we're querying for datetime as a field of event query, this will automatically | |
| 97 | + * set the query to pull datetimes that belong to that event. | |
| 98 | + * We can set more cases for other source types. | |
| 99 | + */ | |
| 100 | +		if (is_object($this->source)) { | |
| 101 | +			switch (true) { | |
| 102 | + // It's surely an event | |
| 103 | + case $this->source instanceof Post: | |
| 104 | + $where_params['EVT_ID'] = $this->source->ID; | |
| 105 | + break; | |
| 106 | + case $this->source instanceof EE_Event: | |
| 107 | + $where_params['EVT_ID'] = $this->source->ID(); | |
| 108 | + break; | |
| 109 | + case $this->source instanceof EE_Ticket: | |
| 110 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); | |
| 111 | + break; | |
| 112 | + case $this->source instanceof EE_Checkin: | |
| 113 | + $where_params['Checkin.CHK_ID'] = $this->source->ID(); | |
| 114 | + break; | |
| 115 | + } | |
| 116 | + } | |
| 117 | + | |
| 118 | + /** | |
| 119 | + * Merge the input_fields with the default query_args | |
| 120 | + */ | |
| 121 | +		if (! empty($input_fields)) { | |
| 122 | + $where_params = array_merge($where_params, $input_fields); | |
| 123 | + } | |
| 124 | + | |
| 125 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); | |
| 126 | + | |
| 127 | + $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | |
| 128 | + | |
| 129 | +		if (! empty($search)) { | |
| 130 | + // use OR operator to search in any of the fields | |
| 131 | + $where_params['OR'] = array( | |
| 132 | +				'DTT_name'        => array('LIKE', '%' . $search . '%'), | |
| 133 | +				'DTT_description' => array('LIKE', '%' . $search . '%'), | |
| 134 | + ); | |
| 135 | + } | |
| 136 | + | |
| 137 | +		if (! empty($this->args['where']['upcoming'])) { | |
| 138 | + $where_params['DTT_EVT_start'] = array( | |
| 139 | + '>', | |
| 140 | +				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | |
| 141 | + ); | |
| 142 | + } | |
| 143 | + | |
| 144 | +		if (! empty($this->args['where']['active'])) { | |
| 145 | + $where_params['DTT_EVT_start'] = array( | |
| 146 | + '<', | |
| 147 | +				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | |
| 148 | + ); | |
| 149 | + $where_params['DTT_EVT_end'] = array( | |
| 150 | + '>', | |
| 151 | +				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') | |
| 152 | + ); | |
| 153 | + } | |
| 154 | + | |
| 155 | +		if (! empty($this->args['where']['expired'])) { | |
| 156 | + $where_params['DTT_EVT_end'] = array( | |
| 157 | + '<', | |
| 158 | +				EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') | |
| 159 | + ); | |
| 160 | + } | |
| 161 | + | |
| 162 | + $where_params = apply_filters( | |
| 163 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_where_params', | |
| 164 | + $where_params, | |
| 165 | + $this->source, | |
| 166 | + $this->args | |
| 167 | + ); | |
| 168 | + | |
| 169 | + $query_args[] = $where_params; | |
| 170 | + | |
| 171 | + /** | |
| 172 | + * Return the $query_args | |
| 173 | + */ | |
| 174 | + return apply_filters( | |
| 175 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_query_args', | |
| 176 | + $query_args, | |
| 177 | + $this->source, | |
| 178 | + $this->args | |
| 179 | + ); | |
| 180 | + } | |
| 181 | + | |
| 182 | + | |
| 183 | + /** | |
| 184 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 185 | + * friendly keys. | |
| 186 | + * | |
| 187 | + * @param array $where_args | |
| 188 | + * @return array | |
| 189 | + */ | |
| 190 | + public function sanitizeInputFields(array $where_args) | |
| 191 | +	{ | |
| 192 | + $arg_mapping = [ | |
| 193 | + 'event' => 'EVT_ID', | |
| 194 | + 'eventIn' => 'EVT_ID', | |
| 195 | + 'eventId' => 'EVT_ID', | |
| 196 | + 'eventIdIn' => 'EVT_ID', | |
| 197 | + 'ticket' => 'Ticket.TKT_ID', | |
| 198 | + 'ticketIn' => 'Ticket.TKT_ID', | |
| 199 | + 'ticketId' => 'Ticket.TKT_ID', | |
| 200 | + 'ticketIdIn' => 'Ticket.TKT_ID', | |
| 201 | + ]; | |
| 202 | + return $this->sanitizeWhereArgsForInputFields( | |
| 203 | + $where_args, | |
| 204 | + $arg_mapping, | |
| 205 | + ['event', 'eventIn', 'ticket', 'ticketIn'] | |
| 206 | + ); | |
| 207 | + } | |
| 208 | 208 | } | 
| @@ -78,14 +78,14 @@ discard block | ||
| 78 | 78 | * Collect the input_fields and sanitize them to prepare them for sending to the Query | 
| 79 | 79 | */ | 
| 80 | 80 | $input_fields = []; | 
| 81 | -        if (! empty($this->args['where'])) { | |
| 81 | +        if ( ! empty($this->args['where'])) { | |
| 82 | 82 | $input_fields = $this->sanitizeInputFields($this->args['where']); | 
| 83 | 83 | |
| 84 | 84 | // Use the proper operator. | 
| 85 | -            if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { | |
| 85 | +            if ( ! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { | |
| 86 | 86 | $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; | 
| 87 | 87 | } | 
| 88 | -            if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { | |
| 88 | +            if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { | |
| 89 | 89 | $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; | 
| 90 | 90 | } | 
| 91 | 91 | } | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | /** | 
| 119 | 119 | * Merge the input_fields with the default query_args | 
| 120 | 120 | */ | 
| 121 | -        if (! empty($input_fields)) { | |
| 121 | +        if ( ! empty($input_fields)) { | |
| 122 | 122 | $where_params = array_merge($where_params, $input_fields); | 
| 123 | 123 | } | 
| 124 | 124 | |
| @@ -126,22 +126,22 @@ discard block | ||
| 126 | 126 | |
| 127 | 127 | $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | 
| 128 | 128 | |
| 129 | -        if (! empty($search)) { | |
| 129 | +        if ( ! empty($search)) { | |
| 130 | 130 | // use OR operator to search in any of the fields | 
| 131 | 131 | $where_params['OR'] = array( | 
| 132 | -                'DTT_name'        => array('LIKE', '%' . $search . '%'), | |
| 133 | -                'DTT_description' => array('LIKE', '%' . $search . '%'), | |
| 132 | +                'DTT_name'        => array('LIKE', '%'.$search.'%'), | |
| 133 | +                'DTT_description' => array('LIKE', '%'.$search.'%'), | |
| 134 | 134 | ); | 
| 135 | 135 | } | 
| 136 | 136 | |
| 137 | -        if (! empty($this->args['where']['upcoming'])) { | |
| 137 | +        if ( ! empty($this->args['where']['upcoming'])) { | |
| 138 | 138 | $where_params['DTT_EVT_start'] = array( | 
| 139 | 139 | '>', | 
| 140 | 140 |                  EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | 
| 141 | 141 | ); | 
| 142 | 142 | } | 
| 143 | 143 | |
| 144 | -        if (! empty($this->args['where']['active'])) { | |
| 144 | +        if ( ! empty($this->args['where']['active'])) { | |
| 145 | 145 | $where_params['DTT_EVT_start'] = array( | 
| 146 | 146 | '<', | 
| 147 | 147 |                  EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 | ); | 
| 153 | 153 | } | 
| 154 | 154 | |
| 155 | -        if (! empty($this->args['where']['expired'])) { | |
| 155 | +        if ( ! empty($this->args['where']['expired'])) { | |
| 156 | 156 | $where_params['DTT_EVT_end'] = array( | 
| 157 | 157 | '<', | 
| 158 | 158 |                  EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') | 
| @@ -15,144 +15,144 @@ | ||
| 15 | 15 | */ | 
| 16 | 16 | class TicketConnectionResolver extends AbstractConnectionResolver | 
| 17 | 17 |  { | 
| 18 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 19 | - public function get_loader_name() | |
| 20 | -    { | |
| 21 | - return 'espresso_ticket'; | |
| 22 | - } | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * @return EEM_Ticket | |
| 26 | - * @throws EE_Error | |
| 27 | - * @throws InvalidArgumentException | |
| 28 | - * @throws InvalidDataTypeException | |
| 29 | - * @throws InvalidInterfaceException | |
| 30 | - */ | |
| 31 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 32 | - public function get_query() | |
| 33 | -    { | |
| 34 | - return EEM_Ticket::instance(); | |
| 35 | - } | |
| 36 | - | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Return an array of item IDs from the query | |
| 40 | - * | |
| 41 | - * @return array | |
| 42 | - */ | |
| 43 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 44 | - public function get_ids() | |
| 45 | -    { | |
| 46 | - $results = $this->query->get_col($this->query_args); | |
| 47 | - | |
| 48 | - return ! empty($results) ? $results : []; | |
| 49 | - } | |
| 50 | - | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Here, we map the args from the input, then we make sure that we're only querying | |
| 54 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 55 | - * handle batch resolution of the posts. | |
| 56 | - * | |
| 57 | - * @return array | |
| 58 | - * @throws EE_Error | |
| 59 | - * @throws InvalidArgumentException | |
| 60 | - * @throws ReflectionException | |
| 61 | - * @throws InvalidDataTypeException | |
| 62 | - * @throws InvalidInterfaceException | |
| 63 | - */ | |
| 64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 65 | - public function get_query_args() | |
| 66 | -    { | |
| 67 | - $where_params = ['TKT_deleted' => ['IN', [true, false]]]; | |
| 68 | - $query_args = []; | |
| 69 | - | |
| 70 | - $query_args['limit'] = $this->getLimit(); | |
| 71 | - | |
| 72 | - // Avoid multiple entries by join. | |
| 73 | - $query_args['group_by'] = 'TKT_ID'; | |
| 74 | - | |
| 75 | - $query_args['default_where_conditions'] = 'minimum'; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 79 | - */ | |
| 80 | - $input_fields = []; | |
| 81 | -        if (! empty($this->args['where'])) { | |
| 82 | - $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 83 | - | |
| 84 | - // Use the proper operator. | |
| 85 | -            if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { | |
| 86 | - $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; | |
| 87 | - } | |
| 88 | - } | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * Determine where we're at in the Graph and adjust the query context appropriately. | |
| 92 | - */ | |
| 93 | -        if ($this->source instanceof EE_Datetime) { | |
| 94 | - $where_params['Datetime.DTT_ID'] = $this->source->ID(); | |
| 95 | - } | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * Merge the input_fields with the default query_args | |
| 99 | - */ | |
| 100 | -        if (! empty($input_fields)) { | |
| 101 | - $where_params = array_merge($where_params, $input_fields); | |
| 102 | - } | |
| 103 | - | |
| 104 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); | |
| 105 | - | |
| 106 | - $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | |
| 107 | - | |
| 108 | -        if (! empty($search)) { | |
| 109 | - // use OR operator to search in any of the fields | |
| 110 | - $where_params['OR'] = array( | |
| 111 | -                'TKT_name'        => array('LIKE', '%' . $search . '%'), | |
| 112 | -                'TKT_description' => array('LIKE', '%' . $search . '%'), | |
| 113 | - ); | |
| 114 | - } | |
| 115 | - | |
| 116 | - $where_params = apply_filters( | |
| 117 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params', | |
| 118 | - $where_params, | |
| 119 | - $this->source, | |
| 120 | - $this->args | |
| 121 | - ); | |
| 122 | - | |
| 123 | - $query_args[] = $where_params; | |
| 124 | - | |
| 125 | - /** | |
| 126 | - * Return the $query_args | |
| 127 | - */ | |
| 128 | - return apply_filters( | |
| 129 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args', | |
| 130 | - $query_args, | |
| 131 | - $this->source, | |
| 132 | - $this->args | |
| 133 | - ); | |
| 134 | - } | |
| 135 | - | |
| 136 | - | |
| 137 | - /** | |
| 138 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 139 | - * friendly keys. | |
| 140 | - * | |
| 141 | - * @param array $where_args | |
| 142 | - * @return array | |
| 143 | - */ | |
| 144 | - public function sanitizeInputFields(array $where_args) | |
| 145 | -    { | |
| 146 | - $arg_mapping = [ | |
| 147 | - 'datetime' => 'Datetime.DTT_ID', | |
| 148 | - 'datetimeIn' => 'Datetime.DTT_ID', | |
| 149 | - 'datetimeIdIn' => 'Datetime.DTT_ID', | |
| 150 | - 'datetimeId' => 'Datetime.DTT_ID', // priority. | |
| 151 | - ]; | |
| 152 | - return $this->sanitizeWhereArgsForInputFields( | |
| 153 | - $where_args, | |
| 154 | - $arg_mapping, | |
| 155 | - ['datetime', 'datetimeIn'] | |
| 156 | - ); | |
| 157 | - } | |
| 18 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 19 | + public function get_loader_name() | |
| 20 | +	{ | |
| 21 | + return 'espresso_ticket'; | |
| 22 | + } | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * @return EEM_Ticket | |
| 26 | + * @throws EE_Error | |
| 27 | + * @throws InvalidArgumentException | |
| 28 | + * @throws InvalidDataTypeException | |
| 29 | + * @throws InvalidInterfaceException | |
| 30 | + */ | |
| 31 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 32 | + public function get_query() | |
| 33 | +	{ | |
| 34 | + return EEM_Ticket::instance(); | |
| 35 | + } | |
| 36 | + | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * Return an array of item IDs from the query | |
| 40 | + * | |
| 41 | + * @return array | |
| 42 | + */ | |
| 43 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 44 | + public function get_ids() | |
| 45 | +	{ | |
| 46 | + $results = $this->query->get_col($this->query_args); | |
| 47 | + | |
| 48 | + return ! empty($results) ? $results : []; | |
| 49 | + } | |
| 50 | + | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Here, we map the args from the input, then we make sure that we're only querying | |
| 54 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers | |
| 55 | + * handle batch resolution of the posts. | |
| 56 | + * | |
| 57 | + * @return array | |
| 58 | + * @throws EE_Error | |
| 59 | + * @throws InvalidArgumentException | |
| 60 | + * @throws ReflectionException | |
| 61 | + * @throws InvalidDataTypeException | |
| 62 | + * @throws InvalidInterfaceException | |
| 63 | + */ | |
| 64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps | |
| 65 | + public function get_query_args() | |
| 66 | +	{ | |
| 67 | + $where_params = ['TKT_deleted' => ['IN', [true, false]]]; | |
| 68 | + $query_args = []; | |
| 69 | + | |
| 70 | + $query_args['limit'] = $this->getLimit(); | |
| 71 | + | |
| 72 | + // Avoid multiple entries by join. | |
| 73 | + $query_args['group_by'] = 'TKT_ID'; | |
| 74 | + | |
| 75 | + $query_args['default_where_conditions'] = 'minimum'; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query | |
| 79 | + */ | |
| 80 | + $input_fields = []; | |
| 81 | +		if (! empty($this->args['where'])) { | |
| 82 | + $input_fields = $this->sanitizeInputFields($this->args['where']); | |
| 83 | + | |
| 84 | + // Use the proper operator. | |
| 85 | +			if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { | |
| 86 | + $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; | |
| 87 | + } | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * Determine where we're at in the Graph and adjust the query context appropriately. | |
| 92 | + */ | |
| 93 | +		if ($this->source instanceof EE_Datetime) { | |
| 94 | + $where_params['Datetime.DTT_ID'] = $this->source->ID(); | |
| 95 | + } | |
| 96 | + | |
| 97 | + /** | |
| 98 | + * Merge the input_fields with the default query_args | |
| 99 | + */ | |
| 100 | +		if (! empty($input_fields)) { | |
| 101 | + $where_params = array_merge($where_params, $input_fields); | |
| 102 | + } | |
| 103 | + | |
| 104 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); | |
| 105 | + | |
| 106 | + $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | |
| 107 | + | |
| 108 | +		if (! empty($search)) { | |
| 109 | + // use OR operator to search in any of the fields | |
| 110 | + $where_params['OR'] = array( | |
| 111 | +				'TKT_name'        => array('LIKE', '%' . $search . '%'), | |
| 112 | +				'TKT_description' => array('LIKE', '%' . $search . '%'), | |
| 113 | + ); | |
| 114 | + } | |
| 115 | + | |
| 116 | + $where_params = apply_filters( | |
| 117 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params', | |
| 118 | + $where_params, | |
| 119 | + $this->source, | |
| 120 | + $this->args | |
| 121 | + ); | |
| 122 | + | |
| 123 | + $query_args[] = $where_params; | |
| 124 | + | |
| 125 | + /** | |
| 126 | + * Return the $query_args | |
| 127 | + */ | |
| 128 | + return apply_filters( | |
| 129 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args', | |
| 130 | + $query_args, | |
| 131 | + $this->source, | |
| 132 | + $this->args | |
| 133 | + ); | |
| 134 | + } | |
| 135 | + | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model | |
| 139 | + * friendly keys. | |
| 140 | + * | |
| 141 | + * @param array $where_args | |
| 142 | + * @return array | |
| 143 | + */ | |
| 144 | + public function sanitizeInputFields(array $where_args) | |
| 145 | +	{ | |
| 146 | + $arg_mapping = [ | |
| 147 | + 'datetime' => 'Datetime.DTT_ID', | |
| 148 | + 'datetimeIn' => 'Datetime.DTT_ID', | |
| 149 | + 'datetimeIdIn' => 'Datetime.DTT_ID', | |
| 150 | + 'datetimeId' => 'Datetime.DTT_ID', // priority. | |
| 151 | + ]; | |
| 152 | + return $this->sanitizeWhereArgsForInputFields( | |
| 153 | + $where_args, | |
| 154 | + $arg_mapping, | |
| 155 | + ['datetime', 'datetimeIn'] | |
| 156 | + ); | |
| 157 | + } | |
| 158 | 158 | } | 
| @@ -78,11 +78,11 @@ discard block | ||
| 78 | 78 | * Collect the input_fields and sanitize them to prepare them for sending to the Query | 
| 79 | 79 | */ | 
| 80 | 80 | $input_fields = []; | 
| 81 | -        if (! empty($this->args['where'])) { | |
| 81 | +        if ( ! empty($this->args['where'])) { | |
| 82 | 82 | $input_fields = $this->sanitizeInputFields($this->args['where']); | 
| 83 | 83 | |
| 84 | 84 | // Use the proper operator. | 
| 85 | -            if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { | |
| 85 | +            if ( ! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { | |
| 86 | 86 | $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; | 
| 87 | 87 | } | 
| 88 | 88 | } | 
| @@ -97,7 +97,7 @@ discard block | ||
| 97 | 97 | /** | 
| 98 | 98 | * Merge the input_fields with the default query_args | 
| 99 | 99 | */ | 
| 100 | -        if (! empty($input_fields)) { | |
| 100 | +        if ( ! empty($input_fields)) { | |
| 101 | 101 | $where_params = array_merge($where_params, $input_fields); | 
| 102 | 102 | } | 
| 103 | 103 | |
| @@ -105,11 +105,11 @@ discard block | ||
| 105 | 105 | |
| 106 | 106 | $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; | 
| 107 | 107 | |
| 108 | -        if (! empty($search)) { | |
| 108 | +        if ( ! empty($search)) { | |
| 109 | 109 | // use OR operator to search in any of the fields | 
| 110 | 110 | $where_params['OR'] = array( | 
| 111 | -                'TKT_name'        => array('LIKE', '%' . $search . '%'), | |
| 112 | -                'TKT_description' => array('LIKE', '%' . $search . '%'), | |
| 111 | +                'TKT_name'        => array('LIKE', '%'.$search.'%'), | |
| 112 | +                'TKT_description' => array('LIKE', '%'.$search.'%'), | |
| 113 | 113 | ); | 
| 114 | 114 | } | 
| 115 | 115 | |