From 44d3b185ae7a15e50bd595440187c6c863a13415 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 15 Feb 2016 14:37:14 +0200 Subject: Merge pull request #4453 from EpicKris/feature/Autoload-Driver-Object-Name Autoload Driver Object Names --- application/config/autoload.php | 5 +++++ system/core/Loader.php | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/application/config/autoload.php b/application/config/autoload.php index 4bc6bf0ad..aeacbdb66 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -72,6 +72,11 @@ $autoload['libraries'] = array(); | Prototype: | | $autoload['drivers'] = array('cache'); +| +| You can also supply an alternative library name to be assigned in +| the controller: +| +| $autoload['drivers'] = array('cache' => 'cch'); */ $autoload['drivers'] = array(); diff --git a/system/core/Loader.php b/system/core/Loader.php index 37d1ecaf9..80de804ea 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -718,9 +718,16 @@ class CI_Loader { { if (is_array($library)) { - foreach ($library as $driver) + foreach ($library as $key => $value) { - $this->driver($driver); + if (is_int($key)) + { + $this->driver($value, $params); + } + else + { + $this->driver($key, $params, $value); + } } return $this; @@ -1334,10 +1341,7 @@ class CI_Loader { // Autoload drivers if (isset($autoload['drivers'])) { - foreach ($autoload['drivers'] as $item) - { - $this->driver($item); - } + $this->driver($autoload['drivers']); } // Load libraries -- cgit v1.2.3-24-g4f1b