Gumbo_Load



Load Class

This is the foundation to all Gumbo Classes. It is responsible for loading Library files into memory. By default, any name supplied with "Gumbo_" prepended to it will be classified as a Gumbo Library Class file. The class defines default rules for such cases. The class is also responsible for loading other file types into memory. This can be accomplished using a load method directly or by creating Load_Settings. The latter is easier.

When the class is loaded, it will automatically define the Home directory. This is the physical location of this class file on the hard drive. The program should then define a Custom directory (if needed). When loading a Gumbo Library Class file, the custom directory, if set, will be checked first.

The class implements the Singleton Interface, which means there is only one instance of this class. It can be accessed directly through the Singleton method or by assigning a variable.

 Gumbo_Load::instance ()->method ();

 // same as
 $load = Gumbo_Load::instance ();
 $load->method ();

There is an overload method defined that works specifically with Gumbo Library Classes. These statements are placed above various class files to ensure that certain required Classes/Interfaces are loaded.

 $load->Gumbo_Valid_Address;

The class implements the Gumbo_Interface_Settings interface. This allows it to save various settings. The Gumbo_Load_Setting extends the generic Gumbo_Setting class. The Gumbo_Load_Setting was specifically designed to be used by this class. It is recommended to define certain settings for certain file types prior to the start of the application. This will make loading specific file types easier by simply passing a key.

 // returns full path based on "templates" setting
 include ($load->load ("template_file", "templates", true));

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

Implements interfaces:

Class Variables

static Gumbo_Interface_Load $_instance =  null [line 82]
string $_dir_custom [line 87]
string $_dir_home [line 85]
Gumbo_Interface_Load_Setting[] $_settings = array () [line 90]

Class Methods

public static Gumbo_Interface_Load instance ( ) [line 110]

Singleton Method


[ Top ]
private Gumbo_Load __construct ( ) [line 99]

Constructor The Constructor will set the primary library home directory. This is the current location of the Gumbo_Load file.


[ Top ]
public void addSetting ( $setting, string $key ) [line 352]

Adds a setting, overwriting the original setting if exists

Parameter(s):

  • postcondition:  remove all non alpha-numeric (except underscores) characters from $key
  • throws:  Gumbo_Exception

[ Top ]
public string getDirCustom ( ) [line 449]

Returns the Custom directory

Implementation of:
Gumbo_Interface_Load::getDirCustom()

[ Top ]
public string getDirHome ( ) [line 441]

Returns the home directory

Implementation of:
Gumbo_Interface_Load::getDirHome()

[ Top ]
public string getFullPath ( string $name, [string|array $dirs], [string $ext], [bool $stretch], [string $separator], [string $path], [string $remove] ) [line 467]

Returns a formatted file path

Parameter(s):

  • (string) $name :: file name
  • (string|array) $dirs :: locations to search through (from path)
  • (string) $ext :: file extension (if null, uses the string from the last dot *.ext)
  • (bool) $stretch :: stretch the file name from the path directory
  • (string) $separator :: stretch separator character (typically "." or "_")
  • (string) $path :: path to start from (default: include) [include|home|absolute]
  • (string) $remove :: removes string pattern from the file name before file search
  • todo:  parse separator by lowercase/uppercase letters
  • throws:  Gumbo_Exception
  • uses:  Gumbo_Load_Setting
Implementation of:
Gumbo_Interface_Load::getFullPath()

[ Top ]
public Gumbo_Interface_Setting getSetting ( string $key ) [line 591]

Returns a single Setting object based on the key

Parameter(s):

  • (string) $key
  • throws:  Gumbo_Exception

[ Top ]
public Gumbo_Interface_Setting[] getSettings ( ) [line 581]

Returns the list of all Settings


[ Top ]
public bool isSetting ( string $key ) [line 616]

Returns if a Setting exists

Parameter(s):

  • (string) $key
  • throws:  Gumbo_Exception

[ Top ]
public mix load ( string $name, [string $key], [ $path_only], bool $return_path ) [line 140]

Quick load of a file using a setting key

The method will require the file name and a key reference. The key will refer to a saved setting, which will be used to the load the file. If no key is defined, or the key doesn't exist, the default settings will be used. The method is a quick wrapper to the Load file method.

The return_path parameter, if set, will return the file name string. This is useful for performing direct includes of templates inside a particular structure.

Parameter(s):

  • (string) $name :: file name
  • (string) $key :: settings reference
  • (bool) $return_path :: returns the formatted path string
  • () $path_only
Implementation of:
Gumbo_Interface_Load::load()

[ Top ]
public bool loadClass ( string $name, [string|array $dirs], [string $ext], [bool $stretch], [string $separator], [string $path], [string $remove] ) [line 222]

Loads a Class file into memory

The load class will load a class file into memory only once. This is so the same class name isn't loaded twice. The stretch setting will separate the class name into components. Each component would represent a sub-directory of the primary path. The separator indicates the character used to separate the directory class names.

For example:

  1.  $load->loadClass ("This_Class_Name"nullnulltrue"_");
The search will look for the following file <path>/this/class/name.class.php where .class.php is the extension

Any class name prepended with Gumbo_* will automatically create the appropriate settings. Simply load the class name.

  1.  $load->loadClass ("Gumbo_Class");

Parameter(s):

  • (string) $name :: class name
  • (string|array) $dirs :: starting locations
  • (string) $ext :: class file extension (default: class.php)
  • (bool) $stretch :: stretch the class name as directories (default: false)
  • (string) $separator :: class name separator (default: "_")
  • (string) $path :: which path to search through (default: "include")
  • (string) $remove :: removes string pattern from the class name when performing a file search
Implementation of:
Gumbo_Interface_Load::loadClass()

[ Top ]
public bool loadFile ( string $name, [string|array $dirs], [string $ext], [bool $once], [bool $use_include], [bool $stretch], [string $separator], [string $path], [string $remove] ) [line 272]

Loads a given class file into memory

Parameter(s):

  • (string) $name :: class name
  • (string|array) $dirs :: locations to search through
  • (string) $ext :: file extension (default: "php")
  • (bool) $once :: loads the file only once (default: false)
  • (bool) $use_include :: use include instead of require (default: false)
  • (bool) $stretch :: stretches the directory path based on the file name (default: false)
  • (string) $separator :: character separating the directory names inside the file name (default: "_")
  • (string) $path :: start path to the file (default: include) [include|home|absolute]
  • (string) $remove :: removes a string pattern from the file name when performing a file search
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Load::loadFile()

[ Top ]
public void removeSetting ( string $key ) [line 372]

Removes a Setting

Parameter(s):

  • (string) $key
  • throws:  Gumbo_Exception

[ Top ]
public void resetSettings ( ) [line 393]

Resets all Settings

  • postcondition:  clears all settings

[ Top ]
public void setDirCustom ( string $loc ) [line 408]

Sets the Custom Class File location

Parameter(s):

  • (string) $loc
  • precondition:  is_dir ($loc)
  • throws:  Gumbo_Exception
Implementation of:
Gumbo_Interface_Load::setDirCustom()

[ Top ]
public bool __get ( string $name ) [line 433]

Loads a class file into memory

Parameter(s):

  • (string) $name :: class name

[ Top ]