How to extend a base class class library? |
[eluser]doors[/eluser]
I am writing a modules class that will be the base class for my other modules such a s payment and shipping. I am writing a test to see if I can extend a library class but it's not working. Let me know where I am going wrong. The test class is as follows. Code: class Test{ Within my controller class I load the ExtendTest class as follows: Code: class Welcome extends Controller{ I am getting an error saying: Fatal error: Class 'Test' not found in ~\system\application\libraries\ExtendTest.php
[eluser]xadio[/eluser]
Where is your ExtendTest.php located? Is your application located in /system/application/? There is a modules library that already exists. I haven't used it, but conceptually it seems good. Matchbox: http://code.google.com/p/matchbox/
[eluser]xadio[/eluser]
According to your controller Code: class Welcome extends Controller{ You can either load the Test Code: class Welcome extends Controller{ Or you could require Test if it is an abstract class: /ExtendTest.php Code: require_once(APPPATH.'/libraries/Test.php');
[eluser]doors[/eluser]
I did the require. I was wondering if seeing that the ExtendTest extends another Class if the loader would load it and let everything flow freely. Thanks.
[eluser]xadio[/eluser]
[strike]I have been working with Loader.php and there is nothing in Loader. This may be because array class_parents( mixed $class [, bool $autoload ] ) is PHP5 specific. CI supports PHP4 so they aren't going to do that. The only thing close is string get_parent_class( mixed $object ) You could extend the Loader.php: /system/application/libraries/MY_Loader.php Code: class MY_Loader extends CI_Loader { Haven't tested, but should work.[/strike]
[eluser]xadio[/eluser]
So that didn't work. I am working on something like this and will post on my results later. |
Welcome Guest, Not a member yet? Register Sign In |