Class ClassLoader

Description

Loader for class and library files

PHP2Go uses the "dot path" syntax to identify a class or library. The first element of the path must point to a include path key, (php2go, the framework default, or a user-defined include path key, defined in the configuration entry INCLUDE_PATH). The following path elements are traduced into a relative path in the file system.

In the path 'php2go.base.Document':

  • php2go is the include path key (internally points to PHP2GO_ROOT . "core/")
  • base.Document is the relative path starting from the include path key root
  • when the file extension is missing, .class.php is used
  • the resolved path would be PHP2GO_ROOT . "core/base/Document.class.php"
ClassLoader has the responsability of traducing paths in the "dot" pattern to real paths pointing to folders, classes, libraries or helper files.

Each processed path is stored in an internal cache, so that it won't be processed twice.

Under PHP4, files and classes are included in the exact moment they're requested. Under PHP5, files are included right away and classes are included on demand, through an __autoload interceptor.

Located in /core/ClassLoader.class.php (line 63)


	
			
Variable Summary
Method Summary
bool importPath (string $path, [string $extension = 'class.php'], [bool $isClass = TRUE])
bool loadDirectory (string $directoryPath)
bool loadFile (string $filePath)
bool _isReadable (string $filePath)
void _registerIncludePath (string $includePath)
bool _translateDotPath (string $dotPath)
bool _validatePath (string $path, string $file, string $extension)
Variables
array $importCache = array() (line 71)

Holds dot paths already processed

  • access: private
array $importClassCache = array() (line 79)

Holds class dot paths already processed

  • access: private
Methods
static method getInstance (line 95)

Get the singleton of the ClassLoader class

static ClassLoader &getInstance ()
Constructor ClassLoader (line 86)

Class constructor

ClassLoader ClassLoader ()
importPath (line 115)

Import the file(s) pointed by the given path

Translates a dot path to a path in the file system pointing to a single file or a set of files, when the wildcard * is present.

  • return: Operation result
  • see: import()
bool importPath (string $path, [string $extension = 'class.php'], [bool $isClass = TRUE])
  • string $path: Dot path
  • string $extension: File(s) extension
  • bool $isClass: Indicates that a class or classes are being imported
loadDirectory (line 158)

Include all files inside a given directory

Operation will stop when the first error is found.

  • return: Operation result
bool loadDirectory (string $directoryPath)
  • string $directoryPath: Directory path
loadFile (line 146)

Include a file given its path in the file system

bool loadFile (string $filePath)
  • string $filePath: File path
_isReadable (line 244)

Check if a given file path is readable

The method also tries to find the file using include_path.

  • access: private
bool _isReadable (string $filePath)
  • string $filePath: File path
_registerIncludePath (line 259)

Register a new entry in PHP's include_path directive

  • access: private
void _registerIncludePath (string $includePath)
  • string $includePath: New include path
_translateDotPath (line 206)

Translate a dot path into a file system path

Determines the real file system path of the file or files. The first path element must match one of the defined include path keys. The other elements are translated into a relative file system path.

  • return: Operation result
  • access: private
bool _translateDotPath (string $dotPath)
  • string $dotPath: Path
_validatePath (line 185)

Checks if a directory or file path is valid

  • access: private
bool _validatePath (string $path, string $file, string $extension)
  • string $path: Path
  • string $file: File
  • string $extension: Extension

Documentation generated on Sun, 07 Oct 2007 19:21:37 -0300 by phpDocumentor 1.3.2