factory() public method

Attempts to return a concrete Hylax_Storage instance based on $driver.
public factory ( string $driver, array $params = [] ) : Hylax_Storage
$driver string The type of concrete Hylax_Storage subclass to return.
$params array A hash containing any additional configuration or connection parameters a subclass might need.
return Hylax_Storage The newly created concrete Hylax_Storage instance, or false on error.
Exemplo n.º 1
0
 /**
  * Attempts to return a reference to a concrete Hylax_Storage instance
  * based on $driver.
  *
  * It will only create a new instance if no Hylax_Storage instance with the
  * same parameters currently exists.
  *
  * This should be used if multiple storage sources are required.
  *
  * This method must be invoked as: $var = &Hylax_Storage::singleton()
  *
  * @param string $driver  The type of concrete Hylax_Storage subclass to
  *                        return.
  * @param array $params   A hash containing any additional configuration or
  *                        connection parameters a subclass might need.
  *
  * @return mixed  The created concrete Hylax_Storage instance, or false on
  *                error.
  */
 function &singleton($driver, $params = array())
 {
     static $instances;
     if (!isset($instances)) {
         $instances = array();
     }
     $signature = serialize(array($driver, $params));
     if (!isset($instances[$signature])) {
         $instances[$signature] =& Hylax_Storage::factory($driver, $params);
     }
     return $instances[$signature];
 }