Skip to content

Commit

Permalink
Merge pull request #2 from elfarqy/master
Browse files Browse the repository at this point in the history
  • Loading branch information
explosivebit authored Dec 22, 2017
2 parents ed85a88 + 858e86b commit 528aa8d
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 21 deletions.
55 changes: 44 additions & 11 deletions Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

namespace explosivebit\arangodb;

use ArangoDBClient\EdgeHandler;
use ArangoDBClient\Export;
use ArangoDBClient\GraphHandler;
use Yii;
use triagens\ArangoDb\CollectionHandler;
use triagens\ArangoDb\ConnectionOptions;
use triagens\ArangoDb\Document;
use triagens\ArangoDb\DocumentHandler;
use triagens\ArangoDb\Statement;
use triagens\ArangoDb\UpdatePolicy;
use ArangoDBClient\CollectionHandler;
use ArangoDBClient\ConnectionOptions;
use ArangoDBClient\Document;
use ArangoDBClient\DocumentHandler;
use ArangoDBClient\Statement;
use ArangoDBClient\UpdatePolicy;

use yii\base\Object;
use yii\base\BaseObject;

class Connection extends Object
class Connection extends BaseObject
{
private $connection = null;

Expand Down Expand Up @@ -42,6 +45,10 @@ class Connection extends Object
private $collectionHandler = null;
/** @var null|DocumentHandler $documentHandler */
private $documentHandler = null;
/** @var null|EdgeHandler $documentHandler */
private $edgeHandler = null;
/** @var null|EdgeHandler $graphHandler */
private $graphHandler = null;

public function init()
{
Expand All @@ -51,16 +58,26 @@ public function init()
try {
Yii::info($token, 'explosivebit\arangodb\Connection::open');
Yii::beginProfile($token, 'explosivebit\arangodb\Connection::open');
$this->connection = new \triagens\ArangoDb\Connection($this->connectionOptions);
$this->connection = new \ArangoDBClient\Connection($this->connectionOptions);
$this->collectionHandler = new CollectionHandler($this->connection);
$this->documentHandler = new DocumentHandler($this->connection);
$this->documentHandler = new DocumentHandler($this->connection);
$this->edgeHandler = new EdgeHandler($this->connection);
$this->graphHandler = new GraphHandler($this->connection);
Yii::endProfile($token, 'explosivebit\arangodb\Connection::open');
} catch (\Exception $ex) {
Yii::endProfile($token, 'explosivebit\arangodb\Connection::open');
throw new \Exception($ex->getMessage(), (int) $ex->getCode(), $ex);
throw new \Exception($ex->getMessage(), (int)$ex->getCode(), $ex);
}
}

/**
* @return EdgeHandler|null
*/
public function getGraphHandler(): EdgeHandler
{
return $this->graphHandler;
}

/**
* @return null|CollectionHandler
*/
Expand All @@ -86,6 +103,14 @@ public function getDocumentHandler()
return $this->documentHandler;
}

/**
* @return null|EdgeHandler
*/
public function getEdgeHandler()
{
return $this->edgeHandler;
}

/**
* @param $collectionId
* @param $documentId
Expand All @@ -104,4 +129,12 @@ public function getStatement($options = [])
{
return new Statement($this->connection, $options);
}

/**
* @param array $options
* @return Export
*/
public function getExport($options = []) {
return new Export($this->connection, $options);
}
}
4 changes: 2 additions & 2 deletions Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace explosivebit\arangodb;

use Yii;
use triagens\ArangoDb\Document;
use triagens\ArangoDb\Statement;
use ArangoDBClient\Document;
use ArangoDBClient\Statement;
use yii\base\Component;
use yii\base\InvalidParamException;
use yii\base\NotSupportedException;
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ return [
'arangodb' => [
'class' => '\explosivebit\arangodb\Connection',
'connectionOptions' => [
triagens\ArangoDb\ConnectionOptions::OPTION_DATABASE => "mydatabase",
triagens\ArangoDb\ConnectionOptions::OPTION_ENDPOINT => 'tcp://127.0.0.1:8529',
triagens\ArangoDb\ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
//triagens\ArangoDb\ConnectionOptions::OPTION_AUTH_USER => '',
//triagens\ArangoDb\ConnectionOptions::OPTION_AUTH_PASSWD => '',
ArangoDBClient\ConnectionOptions::OPTION_DATABASE => "mydatabase",
ArangoDBClient\ConnectionOptions::OPTION_ENDPOINT => 'tcp://127.0.0.1:8529',
ArangoDBClient\ConnectionOptions::OPTION_AUTH_TYPE => 'Basic',
//ArangoDBClient\ConnectionOptions::OPTION_AUTH_USER => '',
//ArangoDBClient\ConnectionOptions::OPTION_AUTH_PASSWD => '',
],
],
],
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "explosivebit/yii2-arangodb",
"name": "elfarqy/yii2-arangodb",
"description": "Yii2 arangodb components",
"type": "yii2-extension",
"keywords": ["yii2","arangodb"],
Expand All @@ -8,12 +8,16 @@
{
"name": "Ilya Rumyantsev",
"email": "[email protected]"
},
{
"name": "Alvian Burhanuddin",
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"require": {
"yiisoft/yii2": "*",
"triagens/arangodb": "*"
"triagens/arangodb": "~3.2"
},
"require-dev": {
"yiisoft/yii2-debug": "*"
Expand All @@ -23,4 +27,4 @@
"explosivebit\\arangodb\\": ""
}
}
}
}

0 comments on commit 528aa8d

Please sign in to comment.