1
|
|
|
<?php |
2
|
|
|
/******************************************************************************* |
3
|
|
|
* This file is part of the GraphQL Bundle package. |
4
|
|
|
* |
5
|
|
|
* (c) YnloUltratech <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
******************************************************************************/ |
10
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Model; |
12
|
|
|
|
13
|
|
|
use Ynlo\GraphQLBundle\Annotation as GraphQL; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @GraphQL\ObjectType() |
17
|
|
|
*/ |
18
|
|
|
class NodeConnection implements ConnectionInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var int |
22
|
|
|
* |
23
|
|
|
* @GraphQL\Field(type="Int!") |
24
|
|
|
*/ |
25
|
|
|
protected $totalCount = 0; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var array |
29
|
|
|
* |
30
|
|
|
* @GraphQL\Field(type="[Ynlo\GraphQLBundle\Model\EdgeInterface]") |
31
|
|
|
*/ |
32
|
|
|
protected $edges = []; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var PageInfo |
36
|
|
|
* |
37
|
|
|
* @GraphQL\Field(type="Ynlo\GraphQLBundle\Model\PageInfo!") |
38
|
|
|
*/ |
39
|
|
|
protected $pageInfo; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* NodeConnection constructor. |
43
|
|
|
*/ |
44
|
6 |
|
public function __construct() |
45
|
|
|
{ |
46
|
6 |
|
$this->pageInfo = new PageInfo(); |
47
|
6 |
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritdoc} |
51
|
|
|
*/ |
52
|
6 |
|
public function getTotalCount(): int |
53
|
|
|
{ |
54
|
6 |
|
return $this->totalCount; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* {@inheritdoc} |
59
|
|
|
*/ |
60
|
6 |
|
public function setTotalCount(int $totalCount) |
61
|
|
|
{ |
62
|
6 |
|
$this->totalCount = $totalCount; |
63
|
6 |
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* {@inheritdoc} |
67
|
|
|
*/ |
68
|
6 |
|
public function addEdge(EdgeInterface $edge) |
69
|
|
|
{ |
70
|
6 |
|
$this->edges[] = $edge; |
71
|
6 |
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* {@inheritdoc} |
75
|
|
|
*/ |
76
|
6 |
|
public function createEdge(NodeInterface $node, string $cursor) |
77
|
|
|
{ |
78
|
6 |
|
return new NodeConnectionEdge($node, $cursor); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* {@inheritdoc} |
83
|
|
|
*/ |
84
|
6 |
|
public function getEdges(): array |
85
|
|
|
{ |
86
|
6 |
|
return $this->edges; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* {@inheritdoc} |
91
|
|
|
*/ |
92
|
|
|
public function setEdges(array $edges) |
93
|
|
|
{ |
94
|
|
|
$this->edges = $edges; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* {@inheritdoc} |
99
|
|
|
*/ |
100
|
6 |
|
public function getPageInfo(): PageInfo |
101
|
|
|
{ |
102
|
6 |
|
return $this->pageInfo; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* {@inheritdoc} |
107
|
|
|
*/ |
108
|
|
|
public function setPageInfo(PageInfo $pageInfo) |
109
|
|
|
{ |
110
|
|
|
$this->pageInfo = $pageInfo; |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|