-
Notifications
You must be signed in to change notification settings - Fork 0
CI_Loader
Loader Class
Loads framework components.
- Class name: CI_Loader
- Namespace:
protected integer $_ci_ob_level
Nesting level of the output buffering mechanism
- Visibility: protected
protected array $_ci_view_paths = array(VIEWPATH => TRUE)
List of paths to load views from
- Visibility: protected
protected array $_ci_library_paths = array(APPPATH, BASEPATH)
List of paths to load libraries from
- Visibility: protected
protected array $_ci_model_paths = array(APPPATH)
List of paths to load models from
- Visibility: protected
protected array $_ci_helper_paths = array(APPPATH, BASEPATH)
List of paths to load helpers from
- Visibility: protected
protected array $_ci_cached_vars = array()
List of cached variables
- Visibility: protected
protected array $_ci_classes = array()
List of loaded classes
- Visibility: protected
protected array $_ci_models = array()
List of loaded models
- Visibility: protected
protected array $_ci_helpers = array()
List of loaded helpers
- Visibility: protected
protected array $_ci_varmap = array('unit_test' => 'unit', 'user_agent' => 'agent')
List of class name mappings
- Visibility: protected
void CI_Loader::__construct()
Class constructor
Sets component load paths, gets the initial output buffering level.
- Visibility: public
void CI_Loader::initialize()
Initializer
- Visibility: public
string|boolean CI_Loader::is_loaded(string $class)
Is Loaded
A utility method to test if a class is in the self::$_ci_classes array.
- Visibility: public
- $class string - <p>Class name to check for</p>
object CI_Loader::library(string $library, array $params, string $object_name)
Library Loader
Loads and instantiates libraries. Designed to be called from application controllers.
- Visibility: public
- $library string - <p>Library name</p>
- $params array - <p>Optional parameters to pass to the library class constructor</p>
- $object_name string - <p>An optional object name to assign to</p>
object CI_Loader::model(string $model, string $name, boolean $db_conn)
Model Loader
Loads and instantiates models.
- Visibility: public
- $model string - <p>Model name</p>
- $name string - <p>An optional object name to assign to</p>
- $db_conn boolean - <p>An optional database connection configuration to initialize</p>
object|boolean CI_Loader::database(mixed $params, boolean $return, boolean $query_builder)
Database Loader
- Visibility: public
- $params mixed - <p>Database configuration options</p>
- $return boolean - <p>Whether to return the database object</p>
- $query_builder boolean - <p>Whether to enable Query Builder (overrides the configuration setting)</p>
object CI_Loader::dbutil(object $db, boolean $return)
Load the Database Utilities Class
- Visibility: public
- $db object - <p>Database object</p>
- $return boolean - <p>Whether to return the DB Utilities class object or not</p>
object CI_Loader::dbforge(object $db, boolean $return)
Load the Database Forge Class
- Visibility: public
- $db object - <p>Database object</p>
- $return boolean - <p>Whether to return the DB Forge class object or not</p>
object|string CI_Loader::view(string $view, array $vars, boolean $return)
View Loader
Loads "view" files.
- Visibility: public
- $view string - <p>View name</p>
- $vars array - <p>An associative array of data to be extracted for use in the view</p>
- $return boolean - <p>Whether to return the view output or leave it to the Output class</p>
object|string CI_Loader::file(string $path, boolean $return)
Generic File Loader
- Visibility: public
- $path string - <p>File path</p>
- $return boolean - <p>Whether to return the file output</p>
object CI_Loader::vars(array|object|string $vars, string $val)
Set Variables
Once variables are set they become available within the controller class and its "view" files.
- Visibility: public
- $vars array|object|string - <p>An associative array or object containing values to be set, or a value's name if string</p>
- $val string - <p>Value to set, only used if $vars is a string</p>
object CI_Loader::clear_vars()
Clear Cached Variables
Clears the cached variables.
- Visibility: public
mixed CI_Loader::get_var(string $key)
Get Variable
Check if a variable is set and retrieve it.
- Visibility: public
- $key string - <p>Variable name</p>
array CI_Loader::get_vars()
Get Variables
Retrieves all loaded variables.
- Visibility: public
object CI_Loader::helper(string|array<mixed,string> $helpers)
Helper Loader
- Visibility: public
- $helpers string|array<mixed,string> - <p>Helper name(s)</p>
object CI_Loader::helpers(string|array<mixed,string> $helpers)
Load Helpers
An alias for the helper() method in case the developer has written the plural form of it.
- Visibility: public
- $helpers string|array<mixed,string> - <p>Helper name(s)</p>
object CI_Loader::language(string|array<mixed,string> $files, $lang)
Language Loader
Loads language files.
- Visibility: public
- $files string|array<mixed,string> - <p>List of language file names to load</p>
- $lang mixed
boolean CI_Loader::config(string $file, boolean $use_sections, boolean $fail_gracefully)
Config Loader
Loads a config file (an alias for CI_Config::load()).
- Visibility: public
- $file string - <p>Configuration file name</p>
- $use_sections boolean - <p>Whether configuration values should be loaded into their own section</p>
- $fail_gracefully boolean - <p>Whether to just return FALSE or display an error message</p>
object|boolean CI_Loader::driver(string|array<mixed,string> $library, array $params, string $object_name)
Driver Loader
Loads a driver library.
- Visibility: public
- $library string|array<mixed,string> - <p>Driver name(s)</p>
- $params array - <p>Optional parameters to pass to the driver</p>
- $object_name string - <p>An optional object name to assign to</p>
object CI_Loader::add_package_path(string $path, boolean $view_cascade)
Add Package Path
Prepends a parent path to the library, model, helper and config path arrays.
- Visibility: public
- $path string - <p>Path to add</p>
- $view_cascade boolean - <p>(default: TRUE)</p>
array CI_Loader::get_package_paths(boolean $include_base)
Get Package Paths
Return a list of all package paths.
- Visibility: public
- $include_base boolean - <p>Whether to include BASEPATH (default: FALSE)</p>
object CI_Loader::remove_package_path(string $path)
Remove Package Path
Remove a path from the library, model, helper and/or config path arrays if it exists. If no path is provided, the most recently added path will be removed removed.
- Visibility: public
- $path string - <p>Path to remove</p>
object CI_Loader::_ci_load(array $_ci_data)
Internal CI Data Loader
Used to load views and files.
Variables are prefixed with ci to avoid symbol collision with variables made available to view files.
- Visibility: protected
- $_ci_data array - <p>Data to load</p>
void CI_Loader::_ci_load_library(string $class, mixed $params, string $object_name)
Internal CI Library Loader
- Visibility: protected
- $class string - <p>Class name to load</p>
- $params mixed - <p>Optional parameters to pass to the class constructor</p>
- $object_name string - <p>Optional object name to assign to</p>
void CI_Loader::_ci_load_stock_library($library_name, string $file_path, mixed $params, string $object_name)
Internal CI Stock Library Loader
- Visibility: protected
- $library_name mixed
- $file_path string - <p>Path to the library filename, relative to libraries/</p>
- $params mixed - <p>Optional parameters to pass to the class constructor</p>
- $object_name string - <p>Optional object name to assign to</p>
void CI_Loader::_ci_init_library(string $class, string $prefix, array|null|boolean $config, string $object_name)
Internal CI Library Instantiator
- Visibility: protected
- $class string - <p>Class name</p>
- $prefix string - <p>Class name prefix</p>
- $config array|null|boolean - <p>Optional configuration to pass to the class constructor: FALSE to skip; NULL to search in config paths; array containing configuration data</p>
- $object_name string - <p>Optional object name to assign to</p>
void CI_Loader::_ci_autoloader()
CI Autoloader
Loads component listed in the config/autoload.php file.
- Visibility: protected
array CI_Loader::_ci_object_to_array(object $object)
CI Object to Array translator
Takes an object as input and converts the class variables to an associative array with key/value pairs.
- Visibility: protected
- $object object - <p>Object data to translate</p>
boolean CI_Loader::_ci_get_component(string $component)
CI Component getter
Get a reference to a specific library or model.
- Visibility: protected
- $component string - <p>Component name</p>
array CI_Loader::_ci_prep_filename(string|array<mixed,string> $filename, string $extension)
Prep filename
This function prepares filenames of various items to make their loading more reliable.
- Visibility: protected
- $filename string|array<mixed,string> - <p>Filename(s)</p>
- $extension string - <p>Filename extension</p>