CFile::getInstance PHP Method

getInstance() public static method

Returns the instance of CFile for the specified file.
public static getInstance ( string $filepath, string $class_name = __CLASS__ ) : object
$filepath string Path to file specified by user.
$class_name string Class name to spawn object for.
return object CFile instance
    public static function getInstance($filepath, $class_name = __CLASS__)
    {
        if ($class_name != __CLASS__ && !is_subclass_of($class_name, __CLASS__)) {
            throw new CFileException('Unable to spawn CFile object from `' . $class_name . '` class');
        }
        if (!array_key_exists($filepath, self::$_instances)) {
            self::$_instances[$filepath] = new $class_name($filepath);
        }
        return self::$_instances[$filepath];
    }

Usage Example

Example #1
0
 public static function getInstance($filepath, $class_name = __CLASS__)
 {
     return parent::getInstance($filepath, __CLASS__);
 }