|
|||
|
I have a interesting question for anyone that can answer it.
I want to create function that verifies that a requested component exists. For example: function isComponent($componentName) { // Code to verify component exists } My question being is there a way to do this or would have just have to do it with a switch. Any help is appreciated. Xistins |
|
|||
|
Okay to clarify...
If say using the above example: isComponent('form') <--- should return true as there is a Zend_Form isComponent('shazbot') <--- would return false because there isn't one. I'm currently doing this with a switch for the different components but I guess I was hoping there was a "prettier" way to do it as this way is rather ugly and a lot of code. As for a little bit more of information I need the ability to also instantiate the component as well. I.E. if(isComponent($requested)) { $this->services[$requested] = new Zend_$requested; } I may have to keep doing this with a switch and that is okay, but I was hoping there was an easier way to do it. Any help is appreciated. X |
|
|||
|
Quote:
{ // Code to verify component exists $filename = '/zend/$componentName'; // suppose your ZendFramwork library dir is /zend/ if (file_exists($filename)) { return true; } else { return false; } } I think if this dir "/zend/form" exists, the component exists |
|
|||
|
I don't want to question what you are trying to do, but I am guessing that it is a waste of time if you are trying to detect if a Zend_Class has been loaded or not. If you are worried about loading a class more than once, just use
PHP Code:
You can just set up the autoloader and not even have to worry about this: PHP Code:
If you are trying to load a class in the library and it isn't even there, then your app should be breaking so that you know you have to fix it. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|