From 0e3263b44d2762894588ff3e682579ec0cb77fa0 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 10 Mar 2011 16:37:35 +0000 Subject: Updated version number in User Guide html. --- user_guide/general/creating_libraries.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 b7b66f0c1..3aedd723f 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.0

CodeIgniter User Guide Version 2.0.1

-- cgit v1.2.3-24-g4f1b From a4d5926d1f40ca9f275a3e26626ac6c8fb605d31 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Mon, 21 Mar 2011 21:00:16 -0400 Subject: Removed closing php in creating libraries. Fixes: #129 --- user_guide/general/creating_libraries.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 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 3aedd723f..6d65f6599 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -101,11 +101,11 @@ they are initialized.



class Someclass {

-    function some_function()
+    public function some_function()
    {
    }
}

-?> +/* End of file Someclass.php */

Using Your Class

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

-    function __construct($params)
+    public function __construct($params)
    {
        // Do something with $params
    }
@@ -243,7 +243,7 @@ class MY_Email extends CI_Email {

class MY_Email extends CI_Email {

-    function __construct()
+    public function __construct()
    {
        parent::__construct();
    }
-- cgit v1.2.3-24-g4f1b From 1f622294b92c095fd91e8ca44912d405c1605ded Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Thu, 7 Apr 2011 12:06:51 -0400 Subject: Wow, I screwed that up, Reactor is going to 2.0.2 not 2.0.1 --- user_guide/general/creating_libraries.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 6d65f6599..8198c18fe 100644 --- a/user_guide/general/creating_libraries.html +++ b/user_guide/general/creating_libraries.html @@ -28,7 +28,7 @@
- +

CodeIgniter User Guide Version 2.0.1

CodeIgniter User Guide Version 2.0.2

-- cgit v1.2.3-24-g4f1b From 114ab0988e20ac6be39ad363ff897a1a3b85e565 Mon Sep 17 00:00:00 2001 From: Razican Date: Mon, 25 Apr 2011 17:26:45 +0200 Subject: Fixed double-space typo. --- 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 8198c18fe..a44ec47b7 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.

  • File names must be capitalized. For example:  Myclass.php
  • -
  • Class declarations must be capitalized. For example:  class Myclass
  • +
  • Class declarations must be capitalized. For example:  class Myclass
  • Class names and file names must match.

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