Class CI_Loader - echiong/testRepo GitHub Wiki
##Class CI_Loader
Loader Class
Loads views and files
Package: [[CodeIgniter<a href="Package CodeIgniter.Libraries.md">Libraries]]
Category:
Loader
Author:
ExpressionEngine Dev Team
Link:
http://codeigniter.com/user_guide/libraries/loader.html
Located at system/core/Loader.php
##Methods summary
public __construct ( )
Constructor
Sets the path to the view files and gets the initial output buffering level
public object initialize ( )
Initialize the Loader
This method is called once in CI_Controller.
Returns
object
public mixed is_loaded ( string $class )
Is Loaded
A utility function to test if a class is in the self::$_ci_classes array. This function returns the object name if the class tested for is loaded, and returns FALSE if it isn't.
It is mainly used in the form_helper -> _get_validation_object()
Parameters
$class
string
class being checked for
Returns
mixed
class object name on the CI SuperObject or FALSE
public library ( string $library = '', mixed $params = NULL, string $object_name = NULL )
Class Loader
This function lets users load and instantiate classes. It is designed to be called from a user's app controllers.
Parameters
$library
string
the name of the class
$params
mixed
the optional parameters
$object_name
string
an optional object name
public model ( string $model, string $name = '', boolean $db_conn = FALSE )
Model Loader
This function lets users load and instantiate models.
Parameters
$model
string
the name of the class
$name
string
name for the model
$db_conn
boolean
database connection
public object database ( string $params = '', boolean $return = FALSE, boolean $active_record = NULL )
Database Loader
Parameters
$params
string
the DB credentials
$return
boolean
whether to return the DB object
$active_record
boolean
whether to enable active record (this allows us to override the config setting)
Returns
object
public string dbutil ( )
Load the Utilities Class
Returns
string
public string dbforge ( )
Load the Database Forge Class
Returns
string
public view ( string $view, array $vars = array(), boolean $return = FALSE )
Load View
This function is used to load a "view" file. It has three parameters:
- The name of the "view" file to be included.
<li>An associative array of data to be extracted for use in the view.</li>
<li>TRUE/FALSE - whether to return the data or load it. In</li>
some cases it's advantageous to be able to return data so that a developer can process it in some way.
Parameters
$view
string
$vars
array
$return
boolean
public string file ( string $path, boolean $return = FALSE )
Load File
This is a generic file loader
Parameters
$path
string
$return
boolean
Returns
string
public vars ( array $vars = array(), string $val = '' )
Set Variables
Once variables are set they become available within the controller class and its "view" files.
Parameters
$vars
array
$val
string
public get_var ( array $key )
Get Variable
Check if a variable is set and retrieve it.
Parameters
$key
array
public helper ( mixed $helpers = array() )
Load Helper
This function loads the specified helper file.
Parameters
$helpers
mixed
public helpers ( array $helpers = array() )
Load Helpers
This is simply an alias to the above function in case the user has written the plural form of this function.
Parameters
$helpers
array
public language ( array $file = array(), string $lang = '' )
Loads a language file
Parameters
$file
array
$lang
string
public config ( string $file = '', boolean $use_sections = FALSE, boolean $fail_gracefully = FALSE )
Loads a config file
Parameters
$file
string
$use_sections
boolean
$fail_gracefully
boolean
public driver ( string $library = '', mixed $params = NULL, string $object_name = NULL )
Driver
Loads a driver library
Parameters
$library
string
the name of the class
$params
mixed
the optional parameters
$object_name
string
an optional object name
public add_package_path ( string $path, boolean $view_cascade = TRUE )
Add Package Path
Prepends a parent path to the library, model, helper, and config path arrays
Parameters
$path
string
$view_cascade
boolean
public get_package_paths ( string $include_base = FALSE )
Get Package Paths
Return a list of all package paths, by default it will ignore BASEPATH.
Parameters
$include_base
string
public type remove_package_path ( type $path = '', boolean $remove_config_path = TRUE )
Remove Package Path
Remove a path from the library, model, and helper path arrays if it exists If no path is provided, the most recently added path is removed.
Parameters
$path
type
$remove_config_path
boolean
Returns
type
protected _ci_load ( array $_ci_data )
Loader
This function is used to load views and files. Variables are prefixed with _ci_ to avoid symbol collision with variables made available to view files
Parameters
$_ci_data
array
protected _ci_load_class ( string $class, mixed $params = NULL, string $object_name = NULL )
Load class
This function loads the requested class.
Parameters
$class
string
the item that is being loaded
$params
mixed
any additional parameters
$object_name
string
an optional object name
protected null _ci_init_class ( string $class, string $prefix = '', boolean $config = FALSE, string $object_name = NULL )
Instantiates a class
Parameters
$class
string
$prefix
string
$config
boolean
$object_name
string
an optional object name
Returns
null
protected array _ci_object_to_array ( object $object )
Object to Array
Takes an object as input and converts the class variables to array key/vals
Parameters
$object
object
Returns
array
protected boolean& _ci_get_component ( string $component )
Get a reference to a specific library or model
Parameters
$component
string
Returns
boolean
protected array _ci_prep_filename ( mixed $filename, string $extension )
Prep filename
This function preps the name of various items to make loading them more reliable.
Parameters
$filename
mixed
$extension
string
Returns
array
<table class="summary" id="properties">
<caption>Properties summary</caption>
<tr data-order="_ci_ob_level" id="$_ci_ob_level">
<td class="attributes"><code>
protected
integer
</code></td>
<td class="name">
$_ci_ob_level
<div class="description detailed">
Nesting level of the output buffering mechanism
</div>
</div></td>
</tr>
<tr data-order="_ci_view_paths" id="$_ci_view_paths">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_view_paths
array()
<div class="description detailed">
List of paths to load views from
</div>
</div></td>
</tr>
<tr data-order="_ci_library_paths" id="$_ci_library_paths">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_library_paths
array()
<div class="description detailed">
List of paths to load libraries from
</div>
</div></td>
</tr>
<tr data-order="_ci_model_paths" id="$_ci_model_paths">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_model_paths
array()
<div class="description detailed">
List of paths to load models from
</div>
</div></td>
</tr>
<tr data-order="_ci_helper_paths" id="$_ci_helper_paths">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_helper_paths
array()
<div class="description detailed">
List of paths to load helpers from
</div>
</div></td>
</tr>
<tr data-order="_base_classes" id="$_base_classes">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_base_classes
array()
<div class="description detailed">
List of loaded base classes Set by the controller class
</div>
</div></td>
</tr>
<tr data-order="_ci_cached_vars" id="$_ci_cached_vars">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_cached_vars
array()
<div class="description detailed">
List of cached variables
</div>
</div></td>
</tr>
<tr data-order="_ci_classes" id="$_ci_classes">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_classes
array()
<div class="description detailed">
List of loaded classes
</div>
</div></td>
</tr>
<tr data-order="_ci_loaded_files" id="$_ci_loaded_files">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_loaded_files
array()
<div class="description detailed">
List of loaded files
</div>
</div></td>
</tr>
<tr data-order="_ci_models" id="$_ci_models">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_models
array()
<div class="description detailed">
List of loaded models
</div>
</div></td>
</tr>
<tr data-order="_ci_helpers" id="$_ci_helpers">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_helpers
array()
<div class="description detailed">
List of loaded helpers
</div>
</div></td>
</tr>
<tr data-order="_ci_varmap" id="$_ci_varmap">
<td class="attributes"><code>
protected
array
</code></td>
<td class="name">
$_ci_varmap
array('unit_test' => 'unit',
'user_agent' => 'agent')