Class mvblog_AutoLoader

Description

AutoLoader class handles auto loading of classes/objects.

Example:

  1.  require_once("mvblog_AutoLoader.php");
  2.  
  3.  $mvblog_AutoLoader new mvblog_AutoLoader();
  4.  
  5.  // Add the directory in which the current file resides to the autoloader.
  6.  $pathInfo pathinfo(__FILE__);
  7.  $mvblog_AutoLoader->registerPath($pathInfo["dirname"]);
  8.  
  9.  // Register the AutoLoader object as the autoloader.
  10.  function __autoload($className{
  11.    global $mvblog_AutoLoader;
  12.    $mvblog_AutoLoader->autoload($className);
  13.  }

Located in /common/mvblog_autoloader.php (line 41)


	
			
Class Constant Summary
Variable Summary
mixed $paths
Method Summary
mvblog_AutoLoader __construct ([array $paths = null])
void autoload (string $className)
bool registerPath (string $path, [string $format = "%s.php"], [ $options = 0])
Variables
mixed $paths = array() (line 44)
  • access: protected
Methods
Constructor __construct (line 56)

Create a new mvblog_AutoLoader object. It will automatically parse

your PHP ini include_path for paths in which is should look for objects. The default format it will look for is "CLASSNAME.php" (case-sensitive). The current directory is usually included in your include_path, so you won't have to add that. Add new paths using ->registerPath($path, $format).

  • access: public
mvblog_AutoLoader __construct ([array $paths = null])
  • array $paths: (optional) An array containing paths and formats. Each element in $paths is an associative array with "path", "format" and "options" keys. I.e. new mvblog_AutoLoader(array(array("path"=>"/usr/share/lib/app", "format" => "class_%s.php", "options" => mvblog_AutoLoader::OPT_LOWERCASE)));
autoload (line 94)

The autoloader. It looks through all the paths and tries to find a file that contains the class to include.

This method should be called from an __autoload() function in your initializing code.

  • access: public
void autoload (string $className)
  • string $className: className. The name of the class to load.
registerPath (line 77)

Add a new path to the list of paths where mvblog_AutoLoader will look for classes.

  • return: false if path is not a dir or not set.
  • access: public
bool registerPath (string $path, [string $format = "%s.php"], [ $options = 0])
  • string $path: The path. This will be automatically expanded to an absolute pathname (i.e. ../../foo will become /var/www/foo/, depending on your current path).
  • string $format: (optional) The format of filenames to look for. %s will be expanded to the classname that needs to be loaded. Example: "class_%s.php".
  • $options
Class Constants
OPT_LOWERCASE = 1 (line 42)

Documentation generated on Fri, 28 Dec 2007 13:17:38 +0100 by phpDocumentor 1.4.1