summaryrefslogtreecommitdiffstats
path: root/user_guide
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-28 08:50:16 +0200
committeradmin <devnull@localhost>2006-09-28 08:50:16 +0200
commit33de9a144aad28763405f8ae2d5c59df5e929b4f (patch)
treee774e7aa9eb99b40979cf2b678aea333dc2de3a5 /user_guide
parent2296fc3ca61b689a2a486d1d39346424c069dc25 (diff)
Diffstat (limited to 'user_guide')
-rw-r--r--user_guide/general/controllers.html1
-rw-r--r--user_guide/general/creating_libraries.html70
2 files changed, 19 insertions, 52 deletions
diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html
index a197299d5..0bfe973e5 100644
--- a/user_guide/general/controllers.html
+++ b/user_guide/general/controllers.html
@@ -381,6 +381,7 @@ is a list of reserved names. Do not name your controller functions any of these
<li>_ci_init_scaffolding</li>
<li>_ci_is_loaded</li>
<li>_ci_load</li>
+<li>_ci_load_class</li>
<li>_ci_scaffolding</li>
<li>_ci_set_view_path</li>
</ul>
diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html
index b047838be..a2d40f95d 100644
--- a/user_guide/general/creating_libraries.html
+++ b/user_guide/general/creating_libraries.html
@@ -63,14 +63,27 @@ Creating Libraries
<h1>Creating Libraries</h1>
<p>When we use the term "Libraries" we are normally referring to the classes that are located in the <kbd>libraries</kbd>
-directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create your own libraries within
-your <dfn>application</dfn> directory in order to maintain separation between your local resources and the global framework resources.</p>
+directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create
+your own libraries within your <dfn>application/libraries</dfn> directory in order to maintain separation between your local resources
+and the global framework resources.</p>
+
+<p>As an added bonus, Code Igniter permits your libraries to <kbd>extend</kbd> native classes if you simply need to add some functionality
+to an existing library. Or you can even replace native libraries just by placing identically named versions in your <dfn>application/libraries</dfn> folder.
+
+<p>In summary:</p>
+
+<ul>
+<li>You can create entirely new libraries.</li>
+<li>You can extend native libraries.</li>
+<li>You can replace native libraries.</li>
+</ul>
+
+
<h2>Storage</h2>
<p>Your library classes should be placed within your <dfn>application/libraries</dfn> folder, as this is where Code Igniter will look for them when
-they are initialized. If your class is named identically to a native class from the <dfn>system/libraries</dfn> folder, your version
-will be used instead.</p>
+they are initialized.</p>
<h2>Naming Conventions</h2>
@@ -87,10 +100,6 @@ will be used instead.</p>
<p>Classes should have this basic prototype (Note: We are using the name <kbd>Myclass</kbd> purely as an example):</p>
<code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');<br />
-<br />
-// Initialize the class<br />
-$obj =& get_instance();<br />
-$obj->init_class('Myclass');
<br /><br />
class Myclass {<br />
<br />
@@ -101,15 +110,6 @@ class Myclass {<br />
?&gt;</code>
-<p>You'll notice in the above example that the class is instantiated directly from the file itself using these two lines of code:</p>
-
-<code>$obj =& get_instance();<br />
-$obj->init_class(<kbd>'Myclass'</kbd>);</code>
-
-<p class="important">Make sure and submit your class name in the first parameter of the <kbd>$obj->init_class()</kbd> function. In the
-above example it is <kbd>Myclass</kbd></p>
-
-
<h2>Using Your Class</h2>
<p>From within any of your <a href="controllers.html">Controller</a> functions you can initialize your class using the standard:</p>
@@ -124,22 +124,6 @@ Code Igniter doesn't care.</p>
<code>$this-><kbd>myclass</kbd>->some_function();&nbsp; // Object instances will always be lower case
</code>
-<h2>Setting a Different Class Variable Name</h2>
-
-
-<p>If you would like the object variable ($this->myclass) set to a different name you can specify it when initializing your class. For
-example, let's initialize it as <kbd>foobar</kbd>:</p>
-
-<code>$obj =& get_instance();<br />
-$obj->init_class('Myclass', <kbd>'foobar'</kbd>);</code>
-
-<p>In the above example you would still load your class like this:</p>
-
-<code>$this->load->library('<kbd>Mclass</kbd>');</code>
-
-<p>But you would use it like this:<p>
-
-<code>$this-><kbd>foobar</kbd>->function();</code>
<h2>Passing Parameters When Initializing Your Class</h2>
@@ -169,25 +153,7 @@ class Myclass {<br />
}<br /><br />
?&gt;</code>
-<p>You can also pass parameters via the third parameter of the <dfn>$obj->init_class()</dfn> function:</p>
-
-<code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');<br />
-<br />
-
-$params = array('type' => 'large', 'color' => 'red');<br /><br />
-
-// Initialize the class<br />
-$obj =& get_instance();<br />
-$obj->init_class('Myclass', 'myclass', $params);
-<br /><br />
-class Myclass {<br />
-<br />
-&nbsp;&nbsp;&nbsp;&nbsp;function Myclass($params)<br />
-&nbsp;&nbsp;&nbsp;&nbsp;{<br />
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Do something with $params<br />
-&nbsp;&nbsp;&nbsp;&nbsp;}<br />
-}<br /><br />
-?&gt;</code>
+<p>You can also pass parameters stored in a config file. Simply create a config file named identically to the class filename.</p>