Kronolith_FreeBusy_View::factory PHP Method

factory() public static method

Attempts to return a concrete Kronolith_FreeBusy_View instance based on $view.
public static factory ( string $view ) : mixed
$view string The type of concrete Kronolith_FreeBusy_View subclass to return.
return mixed The newly created concrete Kronolith_FreeBusy_View instance, or false on an error.
    public static function factory($view)
    {
        $driver = basename($view);
        $class = 'Kronolith_FreeBusy_View_' . $driver;
        if (class_exists($class)) {
            return new $class();
        }
        return false;
    }

Usage Example

示例#1
0
文件: View.php 项目: horde/horde
 /**
  * Attempts to return a reference to a concrete Kronolith_FreeBusy_View
  * instance based on $view.  It will only create a new instance if no
  * Kronolith_FreeBusy_View instance with the same parameters currently
  * exists.
  *
  * This method must be invoked as:
  * $var = &Kronolith_FreeBusy_View::singleton()
  *
  * @param string $view  The type of concrete Kronolith_FreeBusy_View
  *                      subclass to return.
  *
  * @return mixed  The created concrete Kronolith_FreeBusy_View instance, or
  *                false on an error.
  */
 public static function &singleton($view)
 {
     static $instances = array();
     if (!isset($instances[$view])) {
         $instances[$view] = Kronolith_FreeBusy_View::factory($view);
     }
     return $instances[$view];
 }