Gumbo_Interface_Load_Setting
Load Setting Interface
This is a special Setting Interface for the Load Interface. A Load Setting holds rules on how to Load a particular file into memory. A series of Settings can be created for a variety of file types. Each Load Setting element refers to a parameter in one of the Load methods. By defining a Load Setting, the programmer would not have to memorize the entire list arguments required by certain Gumbo_Interface_Load methods, just a key reference.
$load->load ("File_Name", "my_key");
'dirs' This provides a list of directories to search for the possible existence of the file. The list will be searched in the order they are added. The list will be appended to the type of path chosen (see below). This is where the use of a custom directory is important. Place the custom directory ahead of the source path.
'class' This simply indicates that the file name passed is the class name. There are special rules when loading a Class file and a regular file. There can only be one definition of a Class or Interface.
'ext' (file extension) This will define the file extension of the file being passed. The file name passed does not need to include the file extension. If the extension argument is set, then it will replace the extension in the file name (file_name.*.ext). It will only replace the last part of the extension. So, if passing "file_name.class.php" with an extension "inc.php", the search will be for "file_name.class.inc.php". If the extension is not set, the default value will be used.
'once' This will load the file only once. This is useful for files that hold a series of functions or multiple class definitions.
'include' This setting will tell the Loader to use the include[_once] functions instead of the require[_once] functions. The default is require.
'stretch' This setting will expand the file name into additional directory paths. For example, the Gumbo Library is organized using the stretch feature. To find the Gumbo_Valid_Address class, simply go into <gumbo_home[custom]_path>/valid/Address.class.php. The last element of the file name should be the actual file name. The stretch feature will use the separator string (see below) for searching.
'separator' This is a character of string of characters to use to separate the file name into directory paths. The default is an underscore "_" (see example above).
'path' This indicates the starting path of the search. The directories list will be appended to this location, followed by any stretch definitions, then the file name and extension. The path is separated into three areas.
- include (default), uses the include path
- home, indicates the path to the Gumbo Library
- absolute, indicates the directories are from the home path
Author(s): |
Michael Luster <mluster79@yahoo.com> |
License: | New BSD License |
Copyright: | Copyright (c) 2007, iBayou, Michael Luster |
Link: | http://sourceforge.net/projects/phpgumbo |
Version: | 0.0.1 |
Interface Methods
Adds a single directory path to the list
Parameter(s):
- (string) $dir
[ Top ]
Returns if the include function should be used instead of require
[ Top ]
Sets the setting to load a class file
Parameter(s):
- (bool) $val
[ Top ]
Adds a list of directories to the list
There are three ways to set the Directory paths. The first method passes a string, with either a single directory or list of directories separated by the PATH_SEPARATOR constant. The second passes an array, with each element value a different directory. The third involves either of the first two methods, but multiple arguments.
- $this->setDirs ("path1:path2:path3/path4");
- $this->setDirs (array ("path1", "path2", "path3/path4"));
- $this->setDirs ("path1", array ("path2"), "path3/path4:path5");
Parameter(s):
- (array|string) $dirs :: ...[]
[ Top ]
Sets the file extension (leading "." not necessary)
Parameter(s):
- (string) $ext
[ Top ]
Sets to use include instead of require
Parameter(s):
- (bool) $include
[ Top ]
Sets the load only once setting
Parameter(s):
- (bool) $once
[ Top ]
Sets the path to start searching from.
Possible values:
- include: search the include path (default)
- home: start from Gumbo home directory
- absolute: ignores starting point and uses dirs as absolute paths
Parameter(s):
- (string) $path
[ Top ]
Sets a string pattern to remove from the file name before search
Parameter(s):
- (string) $remove
[ Top ]
Sets the stretch separator character
Parameter(s):
- (string) $sep
[ Top ]