Completed
Branch EDTR/master (dbc914)
by
unknown
09:15 queued 40s
created

getConnectionResolver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EventEspresso\core\domain\services\graphql\connections;
4
5
use EEM_Attendee;
6
use EventEspresso\core\domain\services\graphql\connection_resolvers\AttendeeConnectionResolver;
7
use EventEspresso\core\domain\services\graphql\abstracts\AbstractRootQueryConnection;
8
use Exception;
9
10
/**
11
 * Class RootQueryAttendeesConnection
12
 * Description
13
 *
14
 * @package EventEspresso\core\domain\services\graphql\connections
15
 * @author  Manzoor Ahmad Wani
16
 * @since   $VID:$
17
 */
18
class RootQueryAttendeesConnection extends AbstractRootQueryConnection
19
{
20
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
    }
31
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
    }
48
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
    }
63
64
    /**
65
     * Given an optional array of args, this returns the args to be used in the connection
66
     *
67
     * @access public
68
     * @param array $args The args to modify the defaults
69
     *
70
     * @return array
71
     */
72
    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
73
    public static function get_connection_args($args = [])
74
    {
75
        return array_merge(
76
            [
77
                'orderby'      => [
78
                    'type'        => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'],
79
                    'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'),
80
                ],
81
                'regTicket' => [
82
                    'type'        => 'ID',
83
                    'description' => esc_html__(
84
                        'Globally unique registration ticket ID to get the attendees for.',
85
                        'event_espresso'
86
                    ),
87
                ],
88
                'regTicketIn' => [
89
                    'type'        => ['list_of' => 'ID'],
90
                    'description' => esc_html__(
91
                        'Globally unique registration ticket IDs to get the attendees for.',
92
                        'event_espresso'
93
                    ),
94
                ],
95
                'regTicketId' => [
96
                    'type'        => 'Int',
97
                    'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'),
98
                ],
99
                'regTicketIdIn' => [
100
                    'type'        => ['list_of' => 'Int'],
101
                    'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'),
102
                ],
103
                'regStatus' => [
104
                    'type'        => 'EspressoRegistrationStatusEnum',
105
                    'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'),
106
                ],
107
            ],
108
            $args
109
        );
110
    }
111
}
112