1 <?php
2 3 4 5 6 7
8
9 namespace frankmayer\ArangoDbPhpCore\Api\Rest;
10
11 use frankmayer\ArangoDbPhpCore\Api\RestApiInterface;
12 use frankmayer\ArangoDbPhpCore\Protocols\Http\AbstractHttpRequest;
13
14
15 16 17 18 19
20 class Collection extends
21 Api implements
22 RestApiInterface
23 {
24 25 26
27 const API_PATH = '/_api/collection';
28
29 30 31 32 33 34 35 36
37 public function create(
38 $collectionName,
39 $collectionParameters = [],
40 $options = []
41 ) {
42 $request = $this->getRequest();
43
44 $request->options = $options;
45 $request->body = ['name' => $collectionName];
46
47 $request->body = static::array_merge_recursive_distinct($request->body, $collectionParameters);
48 $request->body = json_encode($request->body);
49
50 $request->path = $this->client->fullDatabasePath . static::API_PATH;
51 $request->method = static::METHOD_POST;
52
53 return $this->getReturnObject($request);
54 }
55
56
57 58 59 60 61 62
63 public function drop(
64 $collectionName,
65 $options = []
66 ) {
67
68 $request = $this->getRequest();
69
70 $request->options = $options;
71 $request->path = $this->client->fullDatabasePath . static::API_PATH . '/' . $collectionName;
72 $request->method = static::METHOD_DELETE;
73
74 return $this->getReturnObject($request);
75 }
76
77
78 79 80 81 82 83
84 public function truncate(
85 $collectionName,
86 $options = []
87 ) {
88
89 $request = $this->getRequest();
90
91 $request->options = $options;
92
93 $request->path = $this->client->fullDatabasePath . static::API_PATH . '/' . $collectionName . '/truncate';
94 $request->method = static::METHOD_PUT;
95
96 return $this->getReturnObject($request);
97 }
98
99
100 101 102 103 104
105 public function getAll(
106 $options = []
107 ) {
108
109 $request = $this->getRequest();
110
111 $request->options = $options;
112
113 $request->path = $this->client->fullDatabasePath . static::API_PATH;
114 if (isset($request->options['excludeSystem']) && $request->options['excludeSystem'] === true) {
115 $request->path .= '?excludeSystem=true';
116 }
117
118 $request->method = static::METHOD_GET;
119
120 return $this->getReturnObject($request);
121 }
122 }
123