From 3c6e4851451cd62b02980821cccdd93290463795 Mon Sep 17 00:00:00 2001
From: Kellas Reeves
Date: Wed, 9 Feb 2011 11:57:56 -0600
Subject: cleaned up some redundant code in the Loader->library function
Elaborated on its functionality in the user guide.
---
system/core/Loader.php | 16 +++-------------
user_guide/libraries/loader.html | 7 +++++++
2 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/system/core/Loader.php b/system/core/Loader.php
index ca2f016e7..72497c724 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -79,9 +79,9 @@ class CI_Loader {
{
if (is_array($library))
{
- foreach($library as $read)
+ foreach($library as $class)
{
- $this->library($read);
+ $this->library($class, $params);
}
return;
@@ -97,17 +97,7 @@ class CI_Loader {
$params = NULL;
}
- if (is_array($library))
- {
- foreach ($library as $class)
- {
- $this->_ci_load_class($class, $params, $object_name);
- }
- }
- else
- {
- $this->_ci_load_class($library, $params, $object_name);
- }
+ $this->_ci_load_class($library, $params, $object_name);
}
// --------------------------------------------------------------------
diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html
index af312f4aa..45a9e89a1 100644
--- a/user_guide/libraries/loader.html
+++ b/user_guide/libraries/loader.html
@@ -90,6 +90,10 @@ For example, if you have file located at:
You may nest the file in as many subdirectories as you want.
+Additionally, multiple libraries can be loaded at the same time by passing an array of libraries to the load function.
+
+$this->load->library(array('email', 'table'));
+
Setting options
The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:
@@ -105,6 +109,8 @@ $this->load->library('email', $config);
Config options can usually also be set via a config file. Each library is explained in detail in its own page, so please read the information regarding each one you would like to use.
+Please take note, when multiple libraries are supplied in an array for the first parameter, each will receive the same parameter information.
+
Assigning a Library to a different object name
If the third (optional) parameter is blank, the library will usually be assigned to an object with the same name as the library. For example, if the library is named Session, it
@@ -120,6 +126,7 @@ $this->my_session
+
Please take note, when multiple libraries are supplied in an array for the first parameter, this parameter is discarded.
$this->load->view('file_name', $data, true/false)
--
cgit v1.2.3-24-g4f1b