From 2067d1a727e7eb5e5ffb40e967f3d1fc4c8a41b2 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Thu, 13 Nov 2008 22:59:24 +0000 Subject: Changing EOL style to LF --- user_guide/general/core_classes.html | 368 +++++++++++++++++------------------ 1 file changed, 184 insertions(+), 184 deletions(-) (limited to 'user_guide/general/core_classes.html') diff --git a/user_guide/general/core_classes.html b/user_guide/general/core_classes.html index a81682399..ca95ad334 100644 --- a/user_guide/general/core_classes.html +++ b/user_guide/general/core_classes.html @@ -1,185 +1,185 @@ - - - - - -Creating Core System Classes : CodeIgniter User Guide - - - - - - - - - - - - - - - - - - - - - -
- - - - - -

CodeIgniter User Guide Version 1.7

-
- - - - - - - - - -
- - -
- - - -
- -

Creating Core System Classes

- -

Every time CodeIgniter 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 or even extend the core versions.

- -

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 CodeIgniter core. -

- -

Note:  Messing with a core system class has a lot of implications, so make sure you -know what you are doing before attempting it.

- - -

System Class List

- -

The following is a list of the core system files that are invoked every time CodeIgniter runs:

- - - -

Replacing Core Classes

- -

To use one of your own system classes instead of a default one simply place your version inside your local application/libraries directory:

- -application/libraries/some-class.php - -

If this directory does not exist you can create it.

- -

Any file named identically to one from the list above will be used instead of the one normally used.

- -

Please note that your class must use CI as a prefix. For example, if your file is named Input.php the class will be named:

- - -class CI_Input {

- -} -
- - - -

Extending Core Class

- -

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. -Extending a class is nearly identical to replacing a class with a couple exceptions:

- - - -

For example, to extend the native Input class you'll create a file named application/libraries/MY_Input.php, and declare your class with:

- - -class MY_Input extends CI_Input {

- -}
- -

Note: If you need to use a constructor in your class make sure you extend the parent constructor:

- - -class MY_Input extends CI_Input {
-
-    function My_Input()
-    {
-        parent::CI_Input();
-    }
-}
- -

Tip:  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 is known as "method overriding"). -This allows you to substantially alter the CodeIgniter core.

- -

If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors.

- -class Welcome extends MY_Controller {
-
-    function Welcome()
-    {
-        parent::MY_Controller();
-    }
-
-    function index()
-    {
-        $this->load->view('welcome_message');
-    }
-}
- -

Setting Your Own Prefix

- -

To set your own sub-class prefix, open your application/config/config.php file and look for this item:

- -$config['subclass_prefix'] = 'MY_'; - -

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

- - - - -
- - - - - - + + + + + +Creating Core System Classes : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

CodeIgniter User Guide Version 1.7

+
+ + + + + + + + + +
+ + +
+ + + +
+ +

Creating Core System Classes

+ +

Every time CodeIgniter 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 or even extend the core versions.

+ +

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 CodeIgniter core. +

+ +

Note:  Messing with a core system class has a lot of implications, so make sure you +know what you are doing before attempting it.

+ + +

System Class List

+ +

The following is a list of the core system files that are invoked every time CodeIgniter runs:

+ + + +

Replacing Core Classes

+ +

To use one of your own system classes instead of a default one simply place your version inside your local application/libraries directory:

+ +application/libraries/some-class.php + +

If this directory does not exist you can create it.

+ +

Any file named identically to one from the list above will be used instead of the one normally used.

+ +

Please note that your class must use CI as a prefix. For example, if your file is named Input.php the class will be named:

+ + +class CI_Input {

+ +} +
+ + + +

Extending Core Class

+ +

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. +Extending a class is nearly identical to replacing a class with a couple exceptions:

+ + + +

For example, to extend the native Input class you'll create a file named application/libraries/MY_Input.php, and declare your class with:

+ + +class MY_Input extends CI_Input {

+ +}
+ +

Note: If you need to use a constructor in your class make sure you extend the parent constructor:

+ + +class MY_Input extends CI_Input {
+
+    function My_Input()
+    {
+        parent::CI_Input();
+    }
+}
+ +

Tip:  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 is known as "method overriding"). +This allows you to substantially alter the CodeIgniter core.

+ +

If you are extending the Controller core class, then be sure to extend your new class in your application controller's constructors.

+ +class Welcome extends MY_Controller {
+
+    function Welcome()
+    {
+        parent::MY_Controller();
+    }
+
+    function index()
+    {
+        $this->load->view('welcome_message');
+    }
+}
+ +

Setting Your Own Prefix

+ +

To set your own sub-class prefix, open your application/config/config.php file and look for this item:

+ +$config['subclass_prefix'] = 'MY_'; + +

Please note that all native CodeIgniter libraries are prefixed with CI_ so DO NOT use that as your prefix.

+ + + + +
+ + + + + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b