Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 public static function noClusterForRid(Rid $rid)
 {
     return new self(sprintf('There is no cluster for %s.', $rid->getValue()));
 }