/** * Processes the transaction result after committing. * @param array $results The results array from the server. * @throws TransactionManagerException * @return array */ private function processResult($results) { $processedResults = array(); foreach ($results as $id => $result) { $command = $this->_commands[$id]; switch ($command['action']) { case "PodManager:store": $processed = $this->_toolbox->getPodManager()->processStoreResult($command['object']->getPod(), $result['_rev'], $result['_id']); break; case "PodManager:delete": $this->_toolbox->getPodManager()->processDeleteResult($command['object']->getPod()); $processed = true; break; case "PodManager:load": $parsedId = $this->_toolbox->parseId($result['_id']); if (!$result) { $processed = null; break; } $processed = $this->_toolbox->getPodManager()->convertArrayToPod($command['data']['type'], $result); break; case "Query:getOne": case "Query:getAll": $processed = $result; break; case "Finder:find": case "Finder:findAll": case "Finder:findNear": case "Finder:findAllNear": case "Finder:findWithin": case "Finder:findAllWithin": case "Finder:search": case "Finder:searchAll": if (isset($command['data']['coordinates'])) { $processed = $this->_toolbox->getFinder()->convertToPods($command['data']['type'], $result, $command['data']['coordinates']); } else { $processed = $this->_toolbox->getFinder()->convertToPods($command['data']['type'], $result); } break; case "Finder:findOne": case "Finder:any": case "Finder:findOneNear": case "Finder:findOneWithin": case "Finder:searchForOne": if ($result == null) { $processed = null; break; } if (isset($command['data']['coordinates'])) { $processed = $this->_toolbox->getFinder()->convertToPods($command['data']['type'], array($result), $command['data']['coordinates']); } else { $processed = $this->_toolbox->getFinder()->convertToPods($command['data']['type'], array($result)); } $processed = reset($processed); break; case "GraphManager:getInboundEdges": case "GraphManager:getOutboundEdges": case "GraphManager:getEdges": $processed = $this->_toolbox->getGraphManager()->convertToPods("edge", $result); break; case "GraphManager:getNeighbours": $processed = $this->_toolbox->getGraphManager()->convertToPods("vertex", $result); break; default: throw new TransactionManagerException("Invalid or unimplemented action ({$command['action']}) while processing the transaction results."); } if (array_key_exists($id, $this->_registeredResults)) { $processedResults[$this->_registeredResults[$id]] = $processed; } } return $processedResults; }
/** * Find the pods that are within a radius from this pod.. * You can add an AQL fragment to process the list further, for example: FILTER doc.property != "unwanted value" SORT doc.name LIMIT 10 * This pod will not be included in the returned list. An empty array is returned if no pods are found. * @param $radius The radius in meters. * @param string $aql An optional AQL fragment that will be inserted after the FOR clause so you can FILTER, LIMIT, etc the query. * @param array $params An optional associative array containing parameters to bind to the query. * @param string $placeholder Set this to something else if you do not wish to use "doc" to refer to documents in your query. * @return array */ public function within($radius, $aql = "", $params = array(), $placeholder = "doc") { return $this->_toolbox->getFinder()->findAllWithin($this->getType(), $this->getModel(), $radius, $aql, $params, $placeholder); }
/** * @covers Paradox\Toolbox::getFinder */ public function testGetFinder() { $this->assertInstanceOf('Paradox\\toolbox\\Finder', $this->toolbox->getFinder(), 'Getting the finder did not return a Paradox\\toolbox\\Finder'); }