src/CarteBlanche/Library/AutoObject/AutoObjectMapper.php
protected function buildEntityManager($emname = 'default')
    {
        $em_cfg = CarteBlanche::getConfig($emname.'_entity_manager');

        if (!isset($em_cfg['class'])) {
            throw new \RuntimeException(
                'An entity manager configuration must define a class name!'
            );
        }
        $em_class = $em_cfg['class'];

        if (!isset($em_cfg['options'])) {
            throw new \RuntimeException(
                'An entity manager configuration must define an options array!'
            );
        }

        if (\CarteBlanche\App\Loader::classExists($em_class)) {
            try {
                $em = new $em_class( $em_cfg['options'] );
            } catch ( \Exception $e ) {
                throw new \RuntimeException(
                    sprintf('An error occurred while trying to load entity manager "%s"!', $em_class)
                );
            }
            if (!($em instanceof \CarteBlanche\Interfaces\EntityManagerInterface)) {
                throw new \DomainException(
                    sprintf('An entity manager must implements the "\CarteBlanche\Interfaces\EntityManagerInterface" interface (in "%s")!', $em_class)
                );
            }
        } else {
            throw new \RuntimeException(
                sprintf('Entity manager named "%s" doesn\'t exist!', $em_class)
            );
        }
        return $em;
    }
protected function buildEntityManager($emname = 'default')
    {
        $em_cfg = CarteBlanche::getConfig($emname.'_entity_manager');

        if (!isset($em_cfg['class'])) {
            throw new \RuntimeException(
                'An entity manager configuration must define a class name!'
            );
        }
        $em_class = $em_cfg['class'];

        if (!isset($em_cfg['options'])) {
            throw new \RuntimeException(
                'An entity manager configuration must define an options array!'
            );
        }

        if (\CarteBlanche\App\Loader::classExists($em_class)) {
            try {
                $em = new $em_class( $em_cfg['options'] );
            } catch ( \Exception $e ) {
                throw new \RuntimeException(
                    sprintf('An error occurred while trying to load entity manager "%s"!', $em_class)
                );
            }
            if (!($em instanceof \CarteBlanche\Interfaces\EntityManagerInterface)) {
                throw new \DomainException(
                    sprintf('An entity manager must implements the "\CarteBlanche\Interfaces\EntityManagerInterface" interface (in "%s")!', $em_class)
                );
            }
        } else {
            throw new \RuntimeException(
                sprintf('Entity manager named "%s" doesn\'t exist!', $em_class)
            );
        }
        return $em;
    }
Build a specific entity manager
@param string $emname The name of the entity manager to build
@return object Returns an object to manage the entity