1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LaravelFreelancerNL\Aranguent\Concerns; |
4
|
|
|
|
5
|
|
|
use ArangoDBClient\CollectionHandler as ArangoCollectionHandler; |
6
|
|
|
use ArangoDBClient\DocumentHandler as ArangoDocumentHandler; |
7
|
|
|
use ArangoDBClient\GraphHandler as ArangoGraphHandler; |
8
|
|
|
use ArangoDBClient\StreamingTransactionHandler; |
9
|
|
|
use ArangoDBClient\UserHandler as ArangoUserHandler; |
10
|
|
|
use ArangoDBClient\ViewHandler as ArangoViewHandler; |
11
|
|
|
use LaravelFreelancerNL\Aranguent\Document; |
12
|
|
|
|
13
|
|
|
trait HandlesArangoDb |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
protected $arangoHandlers; |
17
|
|
|
|
18
|
121 |
|
public function getCollectionHandler() |
19
|
|
|
{ |
20
|
121 |
|
if (!isset($this->arangoHandlers['collection'])) { |
21
|
121 |
|
$this->arangoHandlers['collection'] = new ArangoCollectionHandler($this->arangoConnection); |
22
|
121 |
|
$this->arangoHandlers['collection']->setDocumentClass(Document::class); |
23
|
|
|
} |
24
|
|
|
|
25
|
121 |
|
return $this->arangoHandlers['collection']; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getDocumentHandler() |
29
|
|
|
{ |
30
|
|
|
if (!isset($this->arangoHandlers['document'])) { |
31
|
|
|
$this->arangoHandlers['document'] = new ArangoDocumentHandler($this->arangoConnection); |
32
|
|
|
$this->arangoHandlers['document']->setDocumentClass(Document::class); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
return $this->arangoHandlers['document']; |
36
|
|
|
} |
37
|
|
|
|
38
|
121 |
|
public function getGraphHandler() |
39
|
|
|
{ |
40
|
121 |
|
if (!isset($this->arangoHandlers['graph'])) { |
41
|
121 |
|
$this->arangoHandlers['graph'] = new ArangoGraphHandler($this->arangoConnection); |
42
|
121 |
|
$this->arangoHandlers['graph']->setDocumentClass(Document::class); |
43
|
|
|
} |
44
|
|
|
|
45
|
121 |
|
return $this->arangoHandlers['graph']; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getUserHandler() |
49
|
|
|
{ |
50
|
|
|
if (!isset($this->arangoHandlers['user'])) { |
51
|
|
|
$this->arangoHandlers['user'] = new ArangoUserHandler($this->arangoConnection); |
52
|
|
|
$this->arangoHandlers['user']->setDocumentClass(Document::class); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $this->arangoHandlers['user']; |
56
|
|
|
} |
57
|
|
|
|
58
|
121 |
|
public function getViewHandler() |
59
|
|
|
{ |
60
|
121 |
|
if (!isset($this->arangoHandlers['view'])) { |
61
|
121 |
|
$this->arangoHandlers['view'] = new ArangoViewHandler($this->arangoConnection); |
62
|
121 |
|
$this->arangoHandlers['view']->setDocumentClass(Document::class); |
63
|
|
|
} |
64
|
|
|
|
65
|
121 |
|
return $this->arangoHandlers['view']; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Get/set streaming transaction handler |
70
|
|
|
* @return mixed |
71
|
|
|
*/ |
72
|
6 |
|
public function getTransactionHandler() |
73
|
|
|
{ |
74
|
6 |
|
if (!isset($this->arangoHandlers['transaction'])) { |
75
|
6 |
|
$this->arangoHandlers['transaction'] = new StreamingTransactionHandler($this->arangoConnection); |
76
|
|
|
} |
77
|
|
|
|
78
|
6 |
|
return $this->arangoHandlers['transaction']; |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|