Class Ismo_Core_Loaders_FileSystem

Description

This loader loads files from the file system.

Sounds simple huh? The trick is that the files are loaded when needed, so that unnecessary include_once and require_once calls can be avoided.

The files are searched from the configured folder and an optional prefix and postfix might be added to the beginning of the file name.

Located in /Loaders/FileSystem.php (line 40)


	
			
Variable Summary
string $_extension
string $_path
string $_postfix
string $_prefix
Method Summary
Ismo_Core_Loaders_FileSystem Ismo_Core_Loaders_FileSystem ()
string findFile (string $fileName)
mixed &getInstance (string $className)
mixed &openFile (string $fileName)
void setExtension (string $extension)
void setPath (string $path)
void setPostfix (string $postfix)
void setPrefix (string $prefix)
Variables
string $_extension = 'php' (line 54)

The file extension to add to the requested file when searching in the file system for it.

This is by default php (the . will be added automatically) as that's the most common file search for. But one might also use this class to load .ini files for example.

  • access: private
string $_path = '.' (line 68)

The path to the direction from where the files will be searched from.

If this is not changed the file will be searched from the application's directory. I.e. the directory in which the file making the Ismo_Core_Application instance is located.

  • access: private
string $_postfix = '' (line 80)

The postfix which will be appended to the end of the requested file when searching in the file system.

This should not include the extension nor the dot.

string $_prefix = '' (line 89)

The prefix which will be added in front of the requested file when searching in the file system.

  • access: private
Methods
Constructor Ismo_Core_Loaders_FileSystem (line 98)

The constructor.

  • access: public
Ismo_Core_Loaders_FileSystem Ismo_Core_Loaders_FileSystem ()
findFile (line 115)

Returns the full path to a file from the configured path using possible set prefix, postfix and extension if it exists.

This method needs to be implemented

  • return: the full path to the file or
    1. null
    if it wasn't found
  • access: public
string findFile (string $fileName)
  • string $fileName: the name of the file to try to find
getInstance (line 134)

Loads, creates and returns an instance of the requested class.

Tries to load the class from the configured location in the file system and then creates and instance of the class.

  • return: the class instance or
    1. null
    if it couldn't be created
  • access: public
mixed &getInstance (string $className)
  • string $className: the name of the class
openFile (line 165)

Tries to open a file from the configured path using possible set prefix, postfix and extension.

Note It's the callers responsibility to close the returned file handle.

This method needs to be implemented

  • return: a file handle to the file if it was found or
    1. null
    if it wasn't found
  • access: public
mixed &openFile (string $fileName)
  • string $fileName: the name of the file to try to open
setExtension (line 185)

Sets the file extension to use.

Example:

  1. $loader = new Ismo_Core_Loaders_FileSystem();
  2. $loader->setExtension('ini');

  • access: public
void setExtension (string $extension)
  • string $extension: the extension to use
setPath (line 210)

Sets the path which controls in which directory in the file system the files are looked for.

Example:

  1. $loader = new Ismo_Core_Loaders_FileSystem();
  2. $loader->setPath('./states/');
  1. $loader = new Ismo_Core_Loaders_FileSystem();
  2. $loader->setPath('./configs/');

  • access: public
void setPath (string $path)
  • string $path: the path to the directory in which to search for the files
setPostfix (line 229)

Sets the postfix.

Example:

  1. $loader = new Ismo_Core_Loaders_FileSystem();
  2. $loader->setPostfix('_MySpecialPostfix');

  • access: public
void setPostfix (string $postfix)
  • string $postfix: the postfix to use
setPrefix (line 248)

Sets the prefix.

Example:

  1. $loader = new Ismo_Core_Loaders_FileSystem();
  2. $loader->setPrefix('MySpecialPrefix_');

  • access: public
void setPrefix (string $prefix)
  • string $prefix: the prefix to use

Documentation generated on Mon, 14 Jun 2004 11:59:19 +0200 by phpDocumentor 1.3.0RC3