Completed
Branch add-event-dom-data (6e412b)
by
unknown
32:54 queued 23:24
created

RootQueryEventsConnection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 84
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A config() 0 11 1
A get_connection_args() 0 37 1
A getConnectionResolver() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\domain\services\graphql\connections;
4
5
use EEM_Event;
6
use EventEspresso\core\domain\services\graphql\abstracts\AbstractRootQueryConnection;
7
use EventEspresso\core\domain\services\graphql\connection_resolvers\EventConnectionResolver;
8
9
class RootQueryEventsConnection extends AbstractRootQueryConnection
10
{
11
12
    /**
13
     * EventsConnection constructor.
14
     *
15
     * @param EEM_Event $model
16
     */
17
    public function __construct(EEM_Event $model)
18
    {
19
        $this->model = $model;
20
    }
21
22
23
    /**
24
     * @inheritDoc
25
     */
26
    public function config()
27
    {
28
        return [
29
            'fromType'           => 'RootQuery',
30
            'toType'             => $this->namespace . 'Event',
31
            'fromFieldName'      => lcfirst($this->namespace . 'Events'),
32
            'connectionTypeName' => "{$this->namespace}RootQueryEventsConnection",
33
            'connectionArgs'     => self::get_connection_args(),
34
            'resolve'            => [$this, 'resolveConnection'],
35
        ];
36
    }
37
38
    /**
39
     * Given an optional array of args, this returns the args to be used in the connection
40
     *
41
     * @access public
42
     * @param array $args The args to modify the defaults
43
     * @return array
44
     */
45
    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
46
    public static function get_connection_args($args = [])
47
    {
48
        $newArgs = [
49
            'datetime'   => [
50
                'type'        => 'ID',
51
                'description' => esc_html__(
52
                    'Globally unique datetime ID to get the events for.',
53
                    'event_espresso'
54
                ),
55
            ],
56
            'datetimeIn' => [
57
                'type'        => ['list_of' => 'ID'],
58
                'description' => esc_html__(
59
                    'Globally unique datetime IDs to get the events for.',
60
                    'event_espresso'
61
                ),
62
            ],
63
            'orderby'    => [
64
                'type'        => ['list_of' => 'EspressoEventsConnectionOrderbyInput'],
65
                'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'),
66
            ],
67
            'search'     => [
68
                'type'        => 'String',
69
                'description' => esc_html__('The search keywords', 'event_espresso'),
70
            ],
71
        ];
72
73
        $newArgs = apply_filters(
74
            'FHEE__EventEspresso_core_domain_services_graphql_connections__attendee_args',
75
            $newArgs,
76
            $args
77
        );
78
        return array_merge(
79
            $newArgs,
80
            $args
81
        );
82
    }
83
84
85
    /**
86
     * @inheritDoc
87
     */
88
    public function getConnectionResolver($entity, $args, $context, $info)
89
    {
90
        return new EventConnectionResolver($entity, $args, $context, $info);
91
    }
92
}
93