This is something I have yet to touch on, interfaces and abstract classes, and need a bit of help using them. I understand their purpose and logic ( I think ).
I am working on a project that will allow users to buy addons for their website. This website is hosted and maintained by me, but it allows them to manage the data ( they can choose features they want, the template that is installed, etc ).
This is all ran on a component layer so I can easily add these features once they've paid for them ( and there will occasionally be some freebies ).
For the sake of leaving things open for development later ( maybe I will find the need to hire someone to help add new stuff ), I have decided that the component classes should follow a suit. The main admin index checks the required class file, auto instantiates the class ( if defined to do so ), passing important vars to the constructor and calling the performer method. It has a few other required things as well soon that will be sent around to other classes for stats and other things ( again, leaving it open, haven't implemented that yet ).
Basically, what I think I want to use for this is an interface. I have a seperate file for all interfaces ( components, plugins, and a few other things ). I have required the interface class, and in my component, component IMPLEMENTS interface_name.
What I am getting now is an error : interface components not found in file.php. Is there a special way to do this? Does the interface have to exist int he same file, or does it need to be called? I checked the manual, but their examples reside in the same file, which doesn't seem logical in my situation ( because I would have to repeat it over and over ).
The interface needn't be in the same file as the class(es) which implements it but it does need to be included into the script at some point before the class definition.
Ok, never mind, I found the answer. I was requiring the interface after requiring the component file. I required component file, ran a few checks on that then included the interface only if we were supposed to auto instantiate the class, just so I wasnt requiring things I may not need, but can work around it now.
|All times are GMT. The time now is 12:25 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0