/** * Instanciate a PDO-based backend from a t41_Backend_Uri object * * @param t41_Backend_Uri $uri * @param string $alias * @throws t41_Backend_Exception */ public function __construct(Backend\BackendUri $uri, $alias = null) { if (!extension_loaded('ldap')) { throw new Exception(array("BACKEND_REQUIRED_EXT", 'ldap')); } parent::__construct($uri, $alias); $this->_baseDN = $uri->getUrl(); }
/** * Instanciate a PDO-based backend from a t41_Backend_Uri object * * @param \t41\Backed\BackendUri $uri * @param string $alias * @throws \t41\Backend\Adapter\Exception */ public function __construct(Backend\BackendUri $uri, $alias = null) { parent::__construct($uri, $alias); $url = explode('/', $uri->getUrl()); if (isset($url[0])) { $this->_database = $url[0]; } else { require_once 't41/Backend/Exception.php'; throw new Exception('BACKEND_MISSING_DBNAME_PARAM'); } if (isset($url[1])) { $this->_table = $url[1]; } }
/** * Instanciate a XML backend from a t41_Backend_Uri object * * @param t41_Backend_Uri $uri * @param string $alias * @throws t41_Backend_Exception */ public function __construct(Backend\BackendUri $uri, $alias = null) { parent::__construct($uri, $alias); if ($this->_uri->getUrl()) { $this->_path = $this->_uri->getUrl(); $this->_path = str_replace('{basepath}', t41\Core::$basePath, $this->_path); if (substr($this->_path, -1) != DIRECTORY_SEPARATOR) { $this->_path .= DIRECTORY_SEPARATOR; } } else { throw new Exception('BACKEND_MISSING_PATH_PARAM'); } if (!is_readable($this->_path)) { throw new Exception(array('BACKEND_PATH_UNREADABLE', $this->_path)); } if (!is_writable($this->_path)) { throw new Exception(array('BACKEND_PATH_UNWRITABLE', $this->_path)); } }
/** * Instanciate a MongoDB backend from a t41_Backend_Uri object * * @param t41_Backend_Uri $uri * @param string $alias * @throws t41_Backend_Exception */ public function __construct(Backend\BackendUri $uri, $alias = null) { if (!extension_loaded('mongo')) { throw new Exception(array("BACKEND_REQUIRED_EXT", 'mongo')); } parent::__construct($uri, $alias); $url = explode('/', $uri->getUrl()); /* @todo do we need to force database declaration in backend ? */ if (!empty($url[0])) { $this->_database = $url[0]; } else { throw new Exception('BACKEND_MISSING_DBNAME_PARAM'); } if (!empty($url[1])) { $this->_collection = $url[1]; } try { $this->_ressource = new \Mongo($this->_uri->getHost()); } catch (\MongoException $e) { throw new Exception($e->getMessage()); } catch (\InvalidArgumentException $e) { throw new Exception($e->getMessage()); } }
/** * Initialiser un backend à partir d'une Uri * * @param t41_Backend_Uri $uri * @param string $alias */ public function __construct(Backend\BackendUri $uri, $alias = null) { parent::__construct($uri, $alias); }