Esempio n. 1
0
 /**
  * @param ClassMetadata $classMetadata
  * @param Query         $query
  *
  * @return Route
  * @throws MappingException
  */
 protected function selectRoute(ClassMetadata $classMetadata, Query $query)
 {
     if ($this->canUseResourceRoute($classMetadata, $query)) {
         return $classMetadata->getRoute('resource');
     } elseif ($classMetadata->hasRoute('collection')) {
         return $classMetadata->getRoute('collection');
     }
     throw MappingException::routeNotConfigured($classMetadata->getName(), 'collection');
 }
Esempio n. 2
0
 /**
  * Factory method to create type instances
  *
  * @param string $name
  *
  * @return Type
  *
  * @throws MappingException
  */
 public static function getType($name)
 {
     if (!isset(self::$typeObjects[$name])) {
         if (!isset(self::$typesMap[$name])) {
             throw MappingException::unknownType($name);
         }
         self::$typeObjects[$name] = new self::$typesMap[$name]();
     }
     return self::$typeObjects[$name];
 }
Esempio n. 3
0
 /**
  * @param array $mapping
  *
  * @throws MappingException
  */
 private function validateAndCompleteAssociationMapping(array &$mapping)
 {
     $mapping['isOwningSide'] = true;
     if (!isset($mapping['targetEntity'])) {
         throw MappingException::missingTargetEntity($mapping['fieldName']);
     }
 }
 /**
  * Actually loads the metadata from the underlying metadata.
  *
  * @param ClassMetadata      $classMetadata
  * @param ClassMetadata|null $parent
  * @param bool               $rootEntityFound
  * @param array              $nonSuperclassParents All parent class names
  *                                                 that are not marked as mapped superclasses.
  *
  * @throws MappingException
  *
  * @return void
  */
 protected function doLoadMetadata($classMetadata, $parent, $rootEntityFound, array $nonSuperclassParents)
 {
     try {
         $this->getDriver()->loadMetadataForClass($classMetadata->getName(), $classMetadata);
     } catch (\ReflectionException $e) {
         throw MappingException::reflectionFailure($classMetadata->getName(), $e);
     }
 }