Loader
Loader
Global class file loader.
This class contains methods for auto-loading classes from files in the Hazaar library path. Ordinarily there will be no need for developers to use this class directly but it does contain a few methods for working with paths and library files.
This class is not meant to be instantiated directly and instances should be retrieved using the Loader::getInstance()method.
Example
$loader = Hazaar\Loader::getInstance();
!!! notice The loader class is loaded automatically when starting the application. There should be no need to use the Loader instance directly and static methods have been provided for some extra functionality.
!!! warning Instantiating this class directly can have undefined results.
Properties
paths
public array $paths
instance
public Loader $instance
Methods
__construct
Initialise a new loader.
public __construct({Array})
!!! warning Do NOT instantiate this class directly. See Loader::getInstance() on how to get a new Loader instance.
fixDirectorySeparator
public fixDirectorySeparator({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$path | string |
getInstance
public getInstance({Array})
register
Register this loader instance as a class autoloader.
public register({Array})
unregister
Unregister this loader instance as a class autoloader.
public unregister({Array})
addIncludePath
public addIncludePath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$path | string |
addSearchPath
Add a new search path for loading classes from library files.
public addSearchPath({Array})
The path type can be anything if you are using the loader to load your own library files. There are built in path types for loading Hazaar library files.
- FILE_PATH_ROOT - Path that contains the whole project
- FILE_PATH_MODEL - Path contains model classes
- FILE_PATH_VIEW - Path contains view files.
- FILE_PATH_CONTROLLER - Path contains controller classes.
- FILE_PATH_SUPPORT - Path contains support files. Used by the Application::runDirect()method.
- FILE_PATH_CONFIG - Configuration files
Parameters
Parameter | Type | Description |
---|---|---|
$type | string | the path type to add |
$path | string | the path to add |
setSearchPath
Sets the search path for a file type.
public setSearchPath({Array})
This is the same as addSearchPath except that it overwrites any existing paths.
Parameters
Parameter | Type | Description |
---|---|---|
$type | mixed | the path type to add |
$path | mixed | the path to add |
addSearchPaths
Add multiple search paths from an array.
public addSearchPaths({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$array | array | Array containing type/path pairs |
getSearchPaths
Return an array of search paths for this loader instance.
public getSearchPaths({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | string |
isAbsolutePath
public isAbsolutePath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$path | string |
getFilePath
public getFilePath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$type | string | |
$search_file | string | |
$base_path | string | |
$case_insensitive | bool |
resolve
public resolve({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string |
loadClassFromFile
public loadClassFromFile({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$className | `````` |
resolveRealPath
private resolveRealPath({Array})
Parameters
Parameter | Type | Description |
---|---|---|
$filename | string | |
$case_insensitive | bool |
Generated by Hazaar API Doc Generator