Class MachII_util_ClassLoader

Description

Used for loading other classes.

ClassLoader manages several tasks relating to loading PHP class definition files. It translates a Java-style class name into a filepath/filename, attempts to locate the file and loads it. It then maintains a record of the filepath/filename internally.

Located in /MachII/util/ClassLoader.php (line 18)


	
			
Method Summary
MachII_util_ClassLoader __construct ()
void addPath (string $path)
string getClassName (string $class)
string getWebRoot ()
string load (string $path, [string|void $class = null])
string makePath (string $class, [boolean $literal = false])
void restore (array $loaderRestore)
mixed &singleton ([string $get = 'all'])
Methods
Constructor __construct (line 24)

Since this is a static class, block instantiation.

  • internal:
MachII_util_ClassLoader __construct ()
addPath (line 172)

Store the path.

void addPath (string $path)
  • string $path
getClassName (line 187)

Translate a dot notation classname to PEAR-style with underscores.

string getClassName (string $class)
  • string $class
getWebRoot (line 199)

Attempt to discover the document root.

If it can't be determined from $_SERVER variables it is assumed to be the current working directory.

  • static:
string getWebRoot ()
load (line 82)

Load a class file.

Will attempt to load a class file. There are three ways to specify the class to load:

1) MachII_util_ClassLoader::load('MyApp.model.MyClass');

  • filename = MyApp/model/MyClass.php
  • classname = MyApp_model_MyClass
2) MachII_util_ClassLoader::load('AnotherApp/model/MyClass.php', 'MyApp_model_MyClass');
  • filename = AnotherApp/model/MyClass.php
  • classname = MyApp_model_MyClass
3) MachII_util_ClassLoader::load('AnotherApp/model/MyClass.php?MyApp_model_MyClass');
  • filename = MyApp/model/MyClass.php
  • classname = MyApp_model_MyClass
Both path and classname may always be given in Java-style dot notation or their native notation, they will be translated if needed.

string load (string $path, [string|void $class = null])
  • string $path
  • string|void $class
makePath (line 135)

Determine the absolute path of a classfile.

Values may be in dot notation or filesystem notation.

  • MyApp.model.MyClass
  • MyApp/model/MyClass.php
  • MyApp\\model\\MyClass.php
  • MyApp\model\MyClass.php
are all valid and equivalent.

string makePath (string $class, [boolean $literal = false])
  • string $class
  • boolean $literal
restore (line 107)

Load an array of class files.

  • static:
void restore (array $loaderRestore)
  • array $loaderRestore: class filepaths
singleton (line 32)

The storage container.

  • static:
mixed &singleton ([string $get = 'all'])
  • string $get: all|paths|classExtension

Documentation generated on Thu, 20 Jan 2005 10:47:27 -0800 by phpDocumentor 1.3.0RC3