How does contact_form block know of variable initialized inside it's controller??
Permalink
I have been studying and modifying a form block I found on the forum and was wondering if you all could help me understand a rather perplexing bit of code within it?
Specifically there are two files to this block.
One is called contact_form.php and is found inside the /blocks/external_form/forms/ directory. I'll call this one the block file.
The other is a controller file called contact_form.php inside the /blocks/external_form/forms/controller/ directory. I'll call this one the...well...controller file.
Inside the block file there is a section of code that spits out any errors encountered within the controller file to the screen on top of the form.
The variable $error_msg is defined inside the controller file as so...
At the end of the controller file there is a section of code that appends the $error_msg variable to an associative array variable called "identifier" through a call to the set method of the BlockController class.
Now since the block file does not instantiate the BlockController class I assume that it is in existence before the contact_form block code is even executed.
Is that right?
If that is so...does anyone know a way to determine which classes are in existence (having their variables and methods available) before a block's code executes (so that I can potentially make use of them)?
In this case does the associative array called "identifier" act like a global variable to store messages like this error message for use by the block file code?
I hope I am making all this clear. While it may seem that I am delving into this code more than I should I want to create the very best form block I can for my sites and that of my clients and don't like certain aspects of what I have seen so far so I need to understand what is going on so as to make a still better form block.
Any insight on this would be appreciated.
Thanks.
Carlos
Specifically there are two files to this block.
One is called contact_form.php and is found inside the /blocks/external_form/forms/ directory. I'll call this one the block file.
The other is a controller file called contact_form.php inside the /blocks/external_form/forms/controller/ directory. I'll call this one the...well...controller file.
Inside the block file there is a section of code that spits out any errors encountered within the controller file to the screen on top of the form.
The variable $error_msg is defined inside the controller file as so...
$error_msg = '<div id="error_msg">If you are experiencing problems submitting the form please send an email with your query to <b>'.$to.'</b>.</div><hr />';
At the end of the controller file there is a section of code that appends the $error_msg variable to an associative array variable called "identifier" through a call to the set method of the BlockController class.
class ContactFormExternalFormBlockController extends BlockController { ... $this->set('error_msg', $error_msg);
Now since the block file does not instantiate the BlockController class I assume that it is in existence before the contact_form block code is even executed.
Is that right?
If that is so...does anyone know a way to determine which classes are in existence (having their variables and methods available) before a block's code executes (so that I can potentially make use of them)?
In this case does the associative array called "identifier" act like a global variable to store messages like this error message for use by the block file code?
I hope I am making all this clear. While it may seem that I am delving into this code more than I should I want to create the very best form block I can for my sites and that of my clients and don't like certain aspects of what I have seen so far so I need to understand what is going on so as to make a still better form block.
Any insight on this would be appreciated.
Thanks.
Carlos