1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\graphql\connections; |
4
|
|
|
|
5
|
|
|
use EE_Base_Class; |
6
|
|
|
use EEM_Ticket; |
7
|
|
|
use EventEspresso\core\domain\services\graphql\connection_resolvers\TicketConnectionResolver; |
8
|
|
|
use EventEspresso\core\services\graphql\connections\ConnectionBase; |
9
|
|
|
use Exception; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Class DatetimeTicketsConnection |
13
|
|
|
* Description |
14
|
|
|
* |
15
|
|
|
* @package EventEspresso\core\domain\services\graphql\connections |
16
|
|
|
* @author Brent Christensen |
17
|
|
|
* @since $VID:$ |
18
|
|
|
*/ |
19
|
|
|
class DatetimeTicketsConnection extends ConnectionBase |
20
|
|
|
{ |
21
|
|
|
|
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
|
|
|
} |
32
|
|
|
|
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
|
|
|
} |
49
|
|
|
|
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
|
|
|
} |
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
|
|
|
'isDefault' => [ |
103
|
|
|
'type' => 'Boolean', |
104
|
|
|
'description' => esc_html__('Filter the default tickets', 'event_espresso'), |
105
|
|
|
], |
106
|
|
|
'isRequired' => [ |
107
|
|
|
'type' => 'Boolean', |
108
|
|
|
'description' => esc_html__('Filter the required tickets', 'event_espresso'), |
109
|
|
|
], |
110
|
|
|
'isTaxable' => [ |
111
|
|
|
'type' => 'Boolean', |
112
|
|
|
'description' => esc_html__('Filter the taxable tickets', 'event_espresso'), |
113
|
|
|
], |
114
|
|
|
'isTrashed' => [ |
115
|
|
|
'type' => 'Boolean', |
116
|
|
|
'description' => esc_html__('Filter the trashed tickets', 'event_espresso'), |
117
|
|
|
], |
118
|
|
|
]; |
119
|
|
|
|
120
|
|
|
$newArgs = apply_filters( |
121
|
|
|
'FHEE__EventEspresso_core_domain_services_graphql_connections__ticket_args', |
122
|
|
|
$newArgs, |
123
|
|
|
$args |
124
|
|
|
); |
125
|
|
|
return array_merge( |
126
|
|
|
$newArgs, |
127
|
|
|
$args |
128
|
|
|
); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|