Completed
Branch EDTR/gql-server-side (8c11b8)
by
unknown
25:44 queued 17:18
created

RootQueryDatetimesConnection::resolveConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 4
dl 5
loc 5
rs 10
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_Datetime;
7
use EventEspresso\core\domain\services\graphql\connection_resolvers\DatetimeConnectionResolver;
8
use EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection;
9
use EventEspresso\core\services\graphql\connections\ConnectionInterface;
10
use Exception;
11
use WPGraphQL\Type\WPObjectType;
12
13
/**
14
 * Class RootQueryDatetimesConnection
15
 * Description
16
 *
17
 * @package EventEspresso\core\domain\services\graphql\connections
18
 * @author  Brent Christensen
19
 * @since   $VID:$
20
 */
21 View Code Duplication
class RootQueryDatetimesConnection implements ConnectionInterface
22
{
23
24
    /**
25
     * @var EEM_Datetime $model
26
     */
27
    protected $model;
28
29
30
    /**
31
     * DatetimeConnection constructor.
32
     *
33
     * @param EEM_Datetime               $model
34
     */
35
    public function __construct(EEM_Datetime $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'             => 'Datetime',
50
            'fromFieldName'      => 'datetimes',
51
            'connectionTypeName' => 'RootQueryDatetimesConnection',
52
            'connectionArgs'     => EventDatetimesConnection::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 DatetimeConnectionResolver($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