Author: Tamás Millián (tamas.millian@gmail.com)
Inheritance: extends Exception
Exemple #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);
 }
 protected function populateMetadata(ClassMetadata $metadata)
 {
     $associations = array();
     $fields = array();
     $foundIdentifier = false;
     foreach ($metadata->getReflectionClass()->getProperties() as $refProperty) {
         $annotation = $this->getPropertyAnnotation($refProperty);
         if ($annotation) {
             if ('@rid' === $annotation->name) {
                 $foundIdentifier = true;
                 $metadata->setIdentifier($refProperty->getName());
                 $fields[$refProperty->getName()] = $annotation;
             } elseif (in_array($annotation->type, $this->getAssociationTypes())) {
                 $associations[$refProperty->getName()] = $annotation;
             } else {
                 $fields[$refProperty->getName()] = $annotation;
             }
         }
     }
     if (!$foundIdentifier) {
         throw MappingException::missingRid($metadata->getName());
     }
     $metadata->setFields($fields);
     $metadata->setAssociations($associations);
     return $associations;
 }