/** * Tries to identify the class of an rid by matching it against * the clusters in the database * * @param Rid $rid * * @throws MappingException * @return string */ public function identifyClass(Rid $rid) { $map = $this->getMap(); $splitRid = explode(':', ltrim($rid->getValue(), '#')); $clusterId = $splitRid[0]; foreach ($map as $class => $clusters) { if (in_array($clusterId, $clusters)) { return $class; } } throw MappingException::noClusterForRid($rid); }
/** * Executes a query against OrientDB to find the specified RID and finalizes the * hydration result. * * Optionally the query can be executed using the specified fetch plan. * * @param Rid $rid * @param mixed $fetchPlan * @return object|null */ protected function load(Rid $rid, $fetchPlan = null) { $results = $this->getHydrator()->load(array($rid->getValue()), $fetchPlan); if (isset($results) && count($results)) { $record = is_array($results) ? array_shift($results) : $results; $results = $this->getHydrator()->hydrate($record); return $results; } return null; }
public static function noClusterForRid(Rid $rid) { return new self(sprintf('There is no cluster for %s.', $rid->getValue())); }