Example #1
0
 /**
  * @param string $class Entity class name
  *
  * @throws Exception\InvalidArgumentException
  * @throws Exception\EntityException
  */
 public function __construct($class)
 {
     $this->className = (string) $class;
     if (!is_subclass_of($this->className, "UniMapper\\Entity")) {
         throw new Exception\InvalidArgumentException("Class must be subclass of UniMapper\\Entity but " . $this->className . " given!", $this->className);
     }
     $reflection = new \ReflectionClass($this->className);
     $this->fileName = $reflection->getFileName();
     foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
         if ($property->isStatic()) {
             continue;
         }
         $this->publicProperties[] = $property->getName();
     }
     // Register reflection
     self::load($this);
     $docComment = $reflection->getDocComment();
     // Parse adapter
     try {
         $adapter = Reflection\Annotation::parseAdapter($docComment);
         if ($adapter) {
             list($this->adapterName, $this->adapterResource) = $adapter;
         }
     } catch (Exception\AnnotationException $e) {
         throw new Exception\EntityException($e->getMessage(), $this->className, $e->getDefinition());
     }
     // Parse properties
     $this->_parseProperties($docComment);
 }