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\domain\services\graphql\connections\DatetimeTicketsConnection; |
9
|
|
|
use EventEspresso\core\services\graphql\connections\ConnectionInterface; |
10
|
|
|
use Exception; |
11
|
|
|
use WPGraphQL\Type\WPObjectType; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class RootQueryTicketsConnection |
15
|
|
|
* Description |
16
|
|
|
* |
17
|
|
|
* @package EventEspresso\core\domain\services\graphql\connections |
18
|
|
|
* @author Brent Christensen |
19
|
|
|
* @since $VID:$ |
20
|
|
|
*/ |
21
|
|
View Code Duplication |
class RootQueryTicketsConnection implements ConnectionInterface |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var EEM_Ticket $model |
26
|
|
|
*/ |
27
|
|
|
protected $model; |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* TicketConnection constructor. |
32
|
|
|
* |
33
|
|
|
* @param EEM_Ticket $model |
34
|
|
|
*/ |
35
|
|
|
public function __construct(EEM_Ticket $model) |
36
|
|
|
{ |
37
|
|
|
$this->model = $model; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return array |
43
|
|
|
* @since $VID:$ |
44
|
|
|
*/ |
45
|
|
|
public function config() |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
|
|
'fromType' => 'RootQuery', |
49
|
|
|
'toType' => 'Ticket', |
50
|
|
|
'fromFieldName' => 'tickets', |
51
|
|
|
'connectionTypeName' => 'RootQueryTicketsConnection', |
52
|
|
|
'connectionArgs' => DatetimeTicketsConnection::get_connection_args(), |
53
|
|
|
'resolve' => [$this, 'resolveConnection'], |
54
|
|
|
'resolveNode' => [$this, 'resolveNode'] |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param $entity |
61
|
|
|
* @param $args |
62
|
|
|
* @param $context |
63
|
|
|
* @param $info |
64
|
|
|
* @return array |
65
|
|
|
* @throws Exception |
66
|
|
|
* @since $VID:$ |
67
|
|
|
*/ |
68
|
|
|
public function resolveConnection($entity, $args, $context, $info) |
69
|
|
|
{ |
70
|
|
|
$resolver = new TicketConnectionResolver($entity, $args, $context, $info); |
71
|
|
|
return $resolver->get_connection(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param $id |
77
|
|
|
* @param $args |
78
|
|
|
* @param $context |
79
|
|
|
* @param $info |
80
|
|
|
* @return EE_Base_Class |
81
|
|
|
* @since $VID:$ |
82
|
|
|
*/ |
83
|
|
|
public function resolveNode($id, $args, $context, $info) |
84
|
|
|
{ |
85
|
|
|
return $this->model->get_one_by_ID($id); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|