Completed
Branch EDTR/master (0d7008)
by
unknown
34:37 queued 26:06
created

DatetimeTicketsConnection::get_connection_args()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 28
rs 9.472
c 0
b 0
f 0
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 View Code Duplication
    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
        return array_merge(
78
            [
79
                'orderby'      => [
80
                    'type'        => ['list_of' => 'TicketsConnectionOrderbyInput'],
81
                    'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'),
82
                ],
83
                'datetime' => [
84
                    'type'        => 'ID',
85
                    'description' => esc_html__('Globally unique datetime ID to get the tickets for.', 'event_espresso'),
86
                ],
87
                'datetimeIn' => [
88
                    'type'        => ['list_of' => 'ID'],
89
                    'description' => esc_html__('Globally unique datetime IDs to get the tickets for.', 'event_espresso'),
90
                ],
91
                'datetimeId' => [
92
                    'type'        => 'Int',
93
                    'description' => esc_html__('Datetime ID to get the tickets for.', 'event_espresso'),
94
                ],
95
                'datetimeIdIn' => [
96
                    'type'        => ['list_of' => 'Int'],
97
                    'description' => esc_html__('Datetime IDs to get the tickets for.', 'event_espresso'),
98
                ],
99
            ],
100
            $args
101
        );
102
    }
103
}
104