From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- user_guide/general/creating_libraries.html | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'user_guide/general/creating_libraries.html') diff --git a/user_guide/general/creating_libraries.html b/user_guide/general/creating_libraries.html index a44ec47b7..8198c18fe 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -58,7 +58,7 @@ Creating Libraries

Creating Libraries

When we use the term "Libraries" we are normally referring to the classes that are located in the libraries -directory and described in the Class Reference of this user guide. In this case, however, we will instead describe how you can create +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 application/libraries directory in order to maintain separation between your local resources and the global framework resources.

@@ -75,7 +75,7 @@ to an existing library. Or you can even replace native libraries just by placing

The page below explains these three concepts in detail.

-

Note: The Database classes can not be extended or replaced with your own classes. All other classes are able to be replaced/extended.

+

Note: The Database classes can not be extended or replaced with your own classes. All other classes are able to be replaced/extended.

Storage

@@ -88,16 +88,16 @@ they are initialized.

The Class File

-

Classes should have this basic prototype (Note: We are using the name Someclass purely as an example):

+

Classes should have this basic prototype (Note: We are using the name Someclass purely as an example):

-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

@@ -136,7 +136,7 @@ $this->load->library('Someclass', $params);

If you use this feature you must set up your class constructor to expect data:

-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Someclass {

@@ -147,8 +147,8 @@ class Someclass {
}

?>
-

You can also pass parameters stored in a config file. Simply create a config file named identically to the class file name -and store it in your application/config/ folder. Note that if you dynamically pass parameters as described above, +

You can also pass parameters stored in a config file. Simply create a config file named identically to the class file name +and store it in your application/config/ folder. Note that if you dynamically pass parameters as described above, the config file option will not be available.

@@ -202,7 +202,7 @@ etc.

Replacing Native Libraries with Your Versions

Simply by naming your class files identically to a native library will cause CodeIgniter 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 Email library +feature you must name the file and the class declaration exactly the same as the native library. For example, to replace the native Email library you'll create a file named application/libraries/Email.php, and declare your class with:

@@ -222,12 +222,12 @@ class CI_Email {

Extending Native Libraries

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. +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:

  • The class declaration must extend the parent class.
  • -
  • Your new class name and filename must be prefixed with MY_ (this item is configurable. See below.).
  • +
  • Your new class name and filename must be prefixed with MY_ (this item is configurable. See below.).

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

@@ -252,12 +252,12 @@ class MY_Email extends CI_Email {

Loading Your Sub-class

-

To load your sub-class you'll use the standard syntax normally used. DO NOT include your prefix. For example, +

To load your sub-class you'll use the standard syntax normally used. DO NOT include your prefix. For example, to load the example above, which extends the Email class, you will use:

$this->load->library('email'); -

Once loaded you will use the class variable as you normally would for the class you are extending. In the case of +

Once loaded you will use the class variable as you normally would for the class you are extending. In the case of the email class all calls will use:

-- cgit v1.2.3-24-g4f1b