public function register($entity, $entityMap = null)
    {
        // If an object is provider, get the class name from it
        if (!is_string($entity)) {
            $entity = get_class($entity);
        }

        if ($this->isRegisteredEntity($entity)) {
            throw new MappingException("Entity $entity is already registered.");
        }

        if (!class_exists($entity)) {
            throw new MappingException("Class $entity does not exists");
        }

        if ($entityMap === null) {
            $entityMap = $this->getEntityMapInstanceFor($entity);
        }

        if (is_string($entityMap)) {
            $entityMap = new $entityMap();
        }

        if (!$entityMap instanceof EntityMap) {
            throw new MappingException(get_class($entityMap).' must be an instance of EntityMap.');
        }

        $entityMap->setClass($entity);

        $this->entityClasses[$entity] = $entityMap;
    }
public function register($entity, $entityMap = null)
    {
        // If an object is provider, get the class name from it
        if (!is_string($entity)) {
            $entity = get_class($entity);
        }

        if ($this->isRegisteredEntity($entity)) {
            throw new MappingException("Entity $entity is already registered.");
        }

        if (!class_exists($entity)) {
            throw new MappingException("Class $entity does not exists");
        }

        if ($entityMap === null) {
            $entityMap = $this->getEntityMapInstanceFor($entity);
        }

        if (is_string($entityMap)) {
            $entityMap = new $entityMap();
        }

        if (!$entityMap instanceof EntityMap) {
            throw new MappingException(get_class($entityMap).' must be an instance of EntityMap.');
        }

        $entityMap->setClass($entity);

        $this->entityClasses[$entity] = $entityMap;
    }
public function register ( $ entity , $ entityMap = null ) { // If an object is provider, get the class name from it if ( ! is_string ( $ entity ) ) { $ entity = get_class ( $ entity ) ; } if ( $ this -> isRegisteredEntity ( $ entity ) ) { throw new MappingException ( "Entity $entity is already registered." ) ; } if ( ! class_exists ( $ entity ) ) { throw new MappingException ( "Class $entity does not exists" ) ; } if ( $ entityMap === null ) { $ entityMap = $ this -> getEntityMapInstanceFor ( $ entity ) ; } if ( is_string ( $ entityMap ) ) { $ entityMap = new $ entityMap ( ) ; } if ( ! $ entityMap instanceof EntityMap ) { throw new MappingException ( get_class ( $ entityMap ) . ' must be an instance of EntityMap.' ) ; } $ entityMap -> setClass ( $ entity ) ; $ this -> entityClasses [ $ entity ] = $ entityMap ; }
Register an entity.

@param string|\Analogue\ORM\Mappable $entity    entity's class name
@param string|EntityMap              $entityMap map's class name

@throws MappingException

@return void
Register an entity .