Inheritance: extends Exceptio\Exception
Beispiel #1
0
 /**
  * Returns the identifier assigned to the given entity.
  *
  * @param object $xmlEntity
  * @return mixed
  * @override
  */
 public function generate(XmlEntityManager $xem, $xmlEntity)
 {
     $class = $xem->getClassMetadata(get_class($xmlEntity));
     $idField = $class->identifier;
     $value = $class->reflFields[$idField]->getValue($xmlEntity);
     if (isset($value)) {
         if (is_object($value)) {
             // NOTE: Single Columns as associated identifiers only allowed - this constraint it is enforced.
             $identifier = current($xem->getUnitOfWork()->getEntityIdentifier($value));
         } else {
             $identifier = $value;
         }
     } else {
         throw OXMException::entityMissingAssignedId($xmlEntity);
     }
     return $identifier;
 }
 /**
  * Throws an exception if the EntityManager is closed or currently not active.
  *
  * @throws OXMException If the EntityManager is closed.
  */
 private function errorIfClosed()
 {
     if ($this->closed) {
         throw OXMException::entityManagerClosed();
     }
 }
 protected function findMappingFile($className)
 {
     $defaultFileName = str_replace('\\', '.', $className) . $this->fileExtension;
     foreach ($this->paths as $path) {
         if (!isset($this->prefixes[$path])) {
             if (file_exists($path . DIRECTORY_SEPARATOR . $defaultFileName)) {
                 return $path . DIRECTORY_SEPARATOR . $defaultFileName;
             }
             continue;
         }
         $prefix = $this->prefixes[$path];
         if (0 !== strpos($className, $prefix . '\\')) {
             continue;
         }
         $filename = $path . '/' . strtr(substr($className, strlen($prefix) + 1), '\\', '.') . $this->fileExtension;
         if (file_exists($filename)) {
             return $filename;
         }
         throw OXMException::mappingNotFound($className, $filename);
     }
     throw OXMException::mappingNotFound($className, substr($className, strrpos($className, '\\') + 1) . $this->fileExtension);
 }
Beispiel #4
0
 /**
  * Ensures that this Configuration instance contains settings that are
  * suitable for a production environment.
  *
  * @throws OXMException If a configuration setting has a value that is not
  *                      suitable for a production environment.
  */
 public function ensureProductionSettings()
 {
     if (!$this->getMetadataCacheImpl()) {
         throw OXMException::mappingCacheNotConfigured();
     }
 }
Beispiel #5
0
 /**
  * Overrides an already defined type to use a different implementation.
  *
  * @static
  * @param string $name
  * @param string $className
  * @throws OXMException
  */
 public static function overrideType($name, $className)
 {
     if (!isset(self::$_typesMap[$name])) {
         throw OXMException::typeNotFound($name);
     }
     self::$_typesMap[$name] = $className;
     unset(self::$_typeObjects[$name]);
 }
Beispiel #6
0
 /**
  * Persists an xml entity as part of the current unit of work.
  *
  * @param object $xmlEntity The xml entity to persist.
  */
 public function persist($xmlEntity)
 {
     $class = $this->xem->getClassMetadata(get_class($xmlEntity));
     if ($class->isMappedSuperclass) {
         throw OXMException::cannotPersistMappedSuperclass($class->name);
     }
     if (!$class->isRoot) {
         throw OXMException::canOnlyPersistRootClasses($class->name);
     }
     $visited = array();
     $this->doPersist($xmlEntity, $visited);
 }