예제 #1
0
 /**
  * Get settings object
  *
  * See {@link AeSettings} documentation for details
  *
  * @throws AeSettingsException #404 if driver not found
  * @throws AeSettingsException #501 if driver is not an implementation of
  *                             the {@link AeInterface_Settings} interface
  *
  * @param string $driver  driver name
  * @param mixed  $arg,... unlimited number of arguments to pass to the driver
  *
  * @return AeInterface_Settings instance of a selected settings driver
  */
 public static function getInstance($driver = null)
 {
     $driver = (string) $driver;
     if (strpos($driver, '.') && file_exists($driver)) {
         // *** This is definitely a file path
         $args = array($driver);
         $driver = strtolower(substr(strrchr($driver, '.'), 1));
     } else {
         $driver = $driver !== null ? $driver : self::DEFAULT_DRIVER;
         $args = func_get_args();
         $args = array_slice($args, 1);
     }
     $class = 'AeSettings_Driver_' . ucfirst($driver);
     try {
         $instance = AeInstance::get($class, $args);
     } catch (AeInstanceException $e) {
         if ($e->getCode() == 404) {
             throw new AeSettingsException(ucfirst($driver) . ' driver not found', 404);
         }
         throw $e;
     }
     if (!$instance instanceof AeInterface_Settings) {
         throw new AeSettingsException(ucfirst($driver) . ' driver has an invalid access interface', 501);
     }
     return $instance;
 }
예제 #2
0
 /**
  * Get session instance
  *
  * Returns an instance of the AeSession class
  *
  * @param string $driver  Session storage driver to use
  * @param array  $options Session options
  *
  * @return AeSession
  */
 public static function getInstance($driver = null, $options = null)
 {
     $args = func_get_args();
     if (is_array($args[1])) {
         $args[1] = new AeArray($args[1]);
     }
     return AeInstance::get('AeSession', $args, true, false);
 }
예제 #3
0
 /**
  * Get instance
  *
  * Returns an instance of the session connection driver. A session
  * connection driver is an object, which handles reading, writing, removing
  * and garbage collection of the session data
  *
  * @param string  $driver  driver name
  * @param AeArray $options driver options array. See individual driver
  *                         documentation for the list of available options
  *
  * @return AeInterface_Session
  */
 public static function getInstance($driver = null, AeArray $options = null)
 {
     $driver = $driver !== null ? $driver : self::DEFAULT_DRIVER;
     $class = 'AeSession_Driver_' . ucfirst($driver);
     $args = func_get_args();
     $args = array_slice($args, 1);
     try {
         $instance = AeInstance::get($class, $args, true, false);
     } catch (AeInstanceException $e) {
         if ($e->getCode() == 404) {
             throw new AeSessionDriverException(ucfirst($driver) . ' driver not found', 404);
         }
         throw $e;
     }
     if (!$instance instanceof AeInterface_Session) {
         throw new AeSessionDriverException(ucfirst($driver) . ' driver has an invalid access interface', 501);
     }
     return $instance;
 }
예제 #4
0
 public static function wrap($file)
 {
     if ($file instanceof AeString) {
         $file = (string) $file;
     }
     if ($file instanceof AeObject_File) {
         return $file;
     }
     $type = self::type($file);
     if ($type == 'directory') {
         return AeInstance::get('AeDirectory', array($file), true, true);
     }
     if ($type == 'file') {
         return AeInstance::get('AeFile', array($file), true, true);
     }
     throw new AeFileException('Invalid value passed: expecting file or path, ' . AeType::of($file) . ' given', 400);
 }
예제 #5
0
 /**
  * Return iterator instance
  *
  * Returns the iterator instance for a certain AeDirectory object instance.
  * This makes sure we won't have several instances of iterators for the same
  * AeDirectory object. You can still get several instances by cloning the
  * iterator, though.
  *
  * @param AeDirectory $directory
  *
  * @return AeDirectory_Iterator
  */
 public static function getInstance(AeDirectory $directory)
 {
     return AeInstance::get('AeDirectory_Iterator', array($directory), true, false);
 }
예제 #6
0
 /**
  * @param string $path
  *
  * @return AeDirectory
  */
 public static function getInstance($path)
 {
     $path = self::absolutePath($path);
     return AeInstance::get('AeDirectory', array($path), true, false);
 }
예제 #7
0
 /**
  * Return iterator instance
  *
  * Returns the iterator instance for a certain AeArray object instance. This
  * makes sure we won't have several instances of iterators for the same
  * AeArray object. You can still get several instances by cloning the
  * iterator, though.
  *
  * @param AeArray $array
  *
  * @return AeArray_Iterator
  */
 public static function getInstance(AeArray $array)
 {
     return AeInstance::get('AeArray_Iterator', array($array), true, false);
 }
예제 #8
0
 /**
  * Get document
  *
  * Returns an instance of the document. This method can be used to ensure
  * AeDocument remains a singleton across the application. You can still
  * instantiate more than one instance of the class directly, however, if the
  * need arises. Just use the class constructor.
  *
  * @return AeDocument
  */
 public static function getInstance()
 {
     $args = func_get_args();
     return AeInstance::get('AeDocument', $args, true, false);
 }