/** * Commit the transaction. * @return array */ public function commit() { if (!$this->_activeTransaction) { throw new TransactionManagerException("There is no active transaction to commit."); } if (empty($this->_commands)) { throw new TransactionManagerException("There is no transaction operations to commit."); } $commandText = 'function () { var db = require("internal").db; '; //Check if there are graph operations foreach ($this->_commands as $command) { if ($command['isGraph']) { $commandText .= "var g = require('org/arangodb/graph').Graph; var graph = new g('{$this->_toolbox->getGraph()}'); "; break; } } $commandText .= 'var result = {}; '; //Now, add the commands foreach ($this->_commands as $id => $command) { $commandText .= "result.{$id} = {$command['command']} "; } $commandText .= "return result; }"; //Send the transaction $result = $this->executeTransaction($commandText, $this->_collections['read'], $this->_collections['write']); //Process the result $processed = $this->processResult($result); $this->clearTransactionInfo(); return $processed; }
/** * @covers Paradox\Toolbox::getGraph */ public function testGetGraphOnToolboxWithoutGraph() { $this->assertNull($this->toolbox->getGraph(), "The graph should be null since this toolbox does not manage a graph"); }