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
'remove' This is a character or string of characters to remove from the file name prior to searching. For example, when searching for Library files, I would want the library path (home or custom) to be the starting point, followed by the stretch of the file name "Gumbo_Valid_Address". Without remove, the path would be created as '<home>/gumbo/valid/address.class.php'. With remove set to "Gumbo_" (default), the string will be removed prior to setting the file path. Now, the path will be '<home>/valid/address.class.php'. This feature can be used to create a Load Setting for the Zend Framework, using remove as 'Zend_'.

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

public void addDir ( string $dir ) [line 109]

Adds a single directory path to the list

Parameter(s):

  • (string) $dir

[ Top ]
public bool getClass ( ) [line 191]

Returns if the setting is for a class load


[ Top ]
public array getDirs ( ) [line 197]

Returns the list of directory paths


[ Top ]
public string getExtension ( ) [line 203]

Returns the file extension


[ Top ]
public bool getInclude ( ) [line 215]

Returns if the include function should be used instead of require


[ Top ]
public bool getOnce ( ) [line 209]

Returns if the file should be loaded once


[ Top ]
public string getPath ( ) [line 233]

Returns the path to start searching from


[ Top ]
public string getRemove ( ) [line 239]

Returns the remove string pattern


[ Top ]
public string getSeparator ( ) [line 227]

Returns the stretch separator character


[ Top ]
public bool getStretch ( ) [line 221]

Returns if the file name should stretch


[ Top ]
public void setClass ( bool $val ) [line 118]

Sets the setting to load a class file

Parameter(s):

  • (bool) $val

[ Top ]
public void setDirs ( array|string $dirs ) [line 135]

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.

  1. $this->setDirs ("path1:path2:path3/path4");
  2. $this->setDirs (array ("path1", "path2", "path3/path4"));
  3. $this->setDirs ("path1", array ("path2"), "path3/path4:path5");

Parameter(s):

  • (array|string) $dirs :: ...[]

[ Top ]
public void setExtension ( string $ext ) [line 141]

Sets the file extension (leading "." not necessary)

Parameter(s):

  • (string) $ext

[ Top ]
public void setInclude ( bool $include ) [line 153]

Sets to use include instead of require

Parameter(s):

  • (bool) $include

[ Top ]
public void setOnce ( bool $once ) [line 147]

Sets the load only once setting

Parameter(s):

  • (bool) $once

[ Top ]
public void setPath ( string $path ) [line 176]

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 ]
public void setRemove ( string $remove ) [line 182]

Sets a string pattern to remove from the file name before search

Parameter(s):

  • (string) $remove

[ Top ]
public void setSeparator ( string $sep ) [line 165]

Sets the stretch separator character

Parameter(s):

  • (string) $sep

[ Top ]
public void setStretch ( bool $stretch ) [line 159]

Sets to stretch the file name as additional directory paths

Parameter(s):

  • (bool) $stretch

[ Top ]