diff options
author | admin <devnull@localhost> | 2006-09-28 09:26:21 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-28 09:26:21 +0200 |
commit | 79c643da4efcf154254730d78c6532cff3d99d1e (patch) | |
tree | 3e93ab476746c07e0e3a13ac771b9c4aa66f3603 /user_guide | |
parent | e1bf94291750a592b1a9749240f08a3d5edb7d39 (diff) |
Diffstat (limited to 'user_guide')
-rw-r--r-- | user_guide/general/core_classes.html | 40 | ||||
-rw-r--r-- | user_guide/general/creating_libraries.html | 12 |
2 files changed, 45 insertions, 7 deletions
diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html index 66d258dd2..a2da4a81c 100644 --- a/user_guide/general/core_classes.html +++ b/user_guide/general/core_classes.html @@ -63,11 +63,13 @@ Creating Core System Classes <h1>Creating Core System Classes</h1>
<p>Every time Code Igniter runs there are several base classes that are initialized automatically as part of the core framework.
-It is possible, however, to swap any of the core system classes with your own versions. <strong>Most users will never have any need to do this,
-but the option to replace them does exist for those who would like to significantly alter the Code Igniter core.</strong>
+It is possible, however, to swap any of the core system classes with your own versions or even extend the core versions.</p>
+
+<p><strong>Most users will never have any need to do this,
+but the option to replace or extend them does exist for those who would like to significantly alter the Code Igniter core.</strong>
</p>
-<p class="important"><strong>Note:</strong> Replacing a core system class with your own version has a lot of implications, so make sure you
+<p class="important"><strong>Note:</strong> Messing with a core system class has a lot of implications, so make sure you
know what you are doing before attempting it.</p>
@@ -108,6 +110,38 @@ class CI_Input {<br /><br /> +<h2>Extending Core Class</h2>
+
+<p>If all you need to do is add some functionality to an existing library - perhaps add a function or two - then
+it's overkill to replace the entire library with your version. In this case it's better to simply extend the class.</p>
+
+<p>Extending a class is identical to replacing a class with one exception: The class declaration must extend the parent class
+and your new class must be prefixed with <kbd>MY_</kbd>. For example, to extend the native <kbd>Input</kbd> class
+you'll create a file named <dfn>application/libraries/Input.php</dfn>, and declare your class with:</p>
+
+<code>
+class MY_Input extends CI_Input {<br /><br />
+
+}</code>
+
+<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p>
+
+<code>
+class MY_Input extends CI_Input {<br />
+<br />
+ function My_Input()<br />
+ {<br />
+ parent::CI_Input();<br />
+ }<br />
+}</code>
+
+<p>Any functions in your class that are named identically to the functions in the parent class will be used instead of the native ones.
+This allows you to substantially alter the Code Igniter core.</p>
+
+
+
+
+
</div>
<!-- END CONTENT -->
diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index d84cf2e23..e2a57f02a 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -80,6 +80,10 @@ to an existing library. Or you can even replace native libraries just by placing <p>The page below explains these three concepts in detail.</p>
+<p class="important"><strong>Note:</strong> The Database classes can not be extended or replaced with your own classes,
+nor can the main Controller class. All other classes are able to be replaced/extended.</p>
+
+
<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
@@ -203,7 +207,7 @@ etc. <p>Simply by naming your class files identically to a native library will cause Code Igniter to use it instead of the native one. To use this
feature you must name the file and the class declaration exactly the same as the native library. For example, to replace the native <kbd>Email</kbd> library
-you'll create a file named <dfn>application/libraries/email.php</dfn>, and declare your class with:</p>
+you'll create a file named <dfn>application/libraries/Email.php</dfn>, and declare your class with:</p>
<code>
class CI_Email {<br /><br />
@@ -216,6 +220,7 @@ class CI_Email {<br /><br /> <code>$this->load->library('<kbd>email</kbd>');</code>
+<p class="important"><strong>Note:</strong> At thit time the Database classes can not be replaced with your own versions.</p>
<h2>Extending Native Libraries</h2>
@@ -225,15 +230,13 @@ it's overkill to replace the entire library with your version. In this case it' <p>Extending a class is identical to replacing a class with one exception: The class declaration must extend the parent class
and your new class must be prefixed with <kbd>MY_</kbd>. For example, to extend the native <kbd>Email</kbd> class
-you'll create a file named <dfn>application/libraries/email.php</dfn>, and declare your class with:</p>
+you'll create a file named <dfn>application/libraries/Email.php</dfn>, and declare your class with:</p>
<code>
class MY_Email extends CI_Email {<br /><br />
}</code>
-<p>Note: If you need to use a constructor in your class make sure you extend the parent constructor:</p>
-
<code>
class MY_Email extends CI_Email {<br />
<br />
@@ -249,6 +252,7 @@ class MY_Email extends CI_Email {<br /> +
</div>
<!-- END CONTENT -->
|