What's new? | Help | Directory | Sign in
Google
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php

require 'Panda/Loader/Abstract.php';

/**
* A singleton source loader
*
* @package Panda_Loader
* @author Michael Girouard
* @license The New BSD License (http://pandaphp.org/license.html)
*/
class Panda_Loader_Singleton
extends Panda_Loader_Abstract
{
/**
* Returns a singleton instance
*
* @return Panda_Loader_Singleton
*/
public static function singleton()
{
static $Instance;

if ($Instance === null) {
$Instance = new self;
}

return $Instance;
}

/**
* An autoloader which for use with SPL
*
* @param string $className
* @return bool
*/
public static function autoload($className)
{
return self::singleton()->load($className);
}

/**
* Prevents unwanted cloning
*/
private function __clone()
{}
}
Show details Hide details

Change log

r111 by mgirouard on May 04, 2008   Diff
Added private clone method.
Go to: 
Project members, sign in to write a code review

Older revisions

r108 by mgirouard on May 03, 2008   Diff
Created a singleton version of the
loader which affords a simple
autoloading mechanism.
All revisions of this file

File info

Size: 787 bytes, 47 lines