From 519f87a07bd1fe3a9ec037f727628bb6c7c8e251 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 23 Jul 2013 17:16:10 +0300 Subject: Loader changes & optimizations related to issue #2551 --- user_guide_src/source/changelog.rst | 3 +++ user_guide_src/source/libraries/loader.rst | 26 ++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 2bd34c33b..08a8f0b38 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -375,6 +375,8 @@ Release Date: Not Released - ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``` changes include: @@ -596,6 +598,7 @@ Bug fixes for 3.0 - Fixed a bug (#2490) - :doc:`Database Class ` method ``query()`` returning boolean instead of a result object for PostgreSQL-specific *INSERT INTO ... RETURNING* statements. - Fixed a bug (#249) - :doc:`Cache Library ` didn't properly handle Memcache(d) configurations with missing options. - Fixed a bug (#180) - :php:func:`config_item()` didn't take into account run-time configuration changes. +- Fixed a bug (#2551) - :doc:`Loader Library ` method ``library()`` didn't properly check if a class that is being loaded already exits. Version 2.1.4 ============= diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 1597bf1c8..19446a9c8 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -261,6 +261,32 @@ $this->load->config('file_name') This method is an alias of the :doc:`config file loading method `: ``$this->config->load()`` +$this->load->is_loaded('library_name') +====================================== + +The ``is_loaded()`` method allows you to check if a class has already +been loaded or not. + +.. note:: The word "class" here refers to libraries and drivers. + +If the requested class has been loaded, the method returns its assigned +name in the CI Super-object and FALSE if it's not:: + + $this->load->library('form_validation'); + $this->load->is_loaded('Form_validation'); // returns 'form_validation' + + $this->load->is_loaded('Nonexistent_library'); // returns FALSE + +.. important:: If you have more than one instance of a class (assigned to + different properties), then the first one will be returned. + +:: + + $this->load->library('form_validation', $config, 'fv'); + $this->load->library('form_validation'); + + $this->load->is_loaded('Form_validation'); // returns 'fv' + Application "Packages" ====================== -- cgit v1.2.3-24-g4f1b