00001 <?php 00024 class WebRegisterCommand extends BaseCommand implements Commandable, Registerable { 00030 protected function __construct () { 00031 // Call parent constructor 00032 parent::__construct(__CLASS__); 00033 } 00034 00041 public final static function createWebRegisterCommand (CommandResolver $resolverInstance) { 00042 // Get new instance 00043 $commandInstance = new WebRegisterCommand(); 00044 00045 // Set the application instance 00046 $commandInstance->setResolverInstance($resolverInstance); 00047 00048 // Return the prepared instance 00049 return $commandInstance; 00050 } 00051 00059 public function execute (Requestable $requestInstance, Responseable $responseInstance) { 00060 // Set request instance as extra instance 00061 Registry::getRegistry()->addInstance('extra', $this); 00062 00063 // Get the application instance 00064 $appInstance = $this->getResolverInstance()->getApplicationInstance(); 00065 00066 // Prepare a template instance 00067 $templateInstance = $this->prepareTemplateInstance($appInstance); 00068 00069 // Assign all the application's data with template variables 00070 $templateInstance->assignApplicationData($appInstance); 00071 00072 // Assign base URL 00073 $templateInstance->assignConfigVariable('base_url'); 00074 00075 // Load the master template 00076 $masterTemplate = $appInstance->getMasterTemplate(); 00077 00078 // Load header template 00079 $templateInstance->loadCodeTemplate('header'); 00080 00081 // Compile and assign it with a variable 00082 $templateInstance->compileTemplate(); 00083 $templateInstance->assignTemplateWithVariable('header', 'header'); 00084 00085 // Load footer template 00086 $templateInstance->loadCodeTemplate('footer'); 00087 00088 // Compile and assign it with a variable 00089 $templateInstance->compileTemplate(); 00090 $templateInstance->assignTemplateWithVariable('footer', 'footer'); 00091 00092 // Load the register template 00093 $templateInstance->loadCodeTemplate('register_form'); 00094 00095 // Assign the register template with the master template as a content ... ;) 00096 $templateInstance->compileTemplate(); 00097 $templateInstance->assignTemplateWithVariable('register_form', 'content'); 00098 00099 // Load the master template 00100 $templateInstance->loadCodeTemplate($masterTemplate); 00101 00102 // Set title 00103 $templateInstance->assignVariable('title', $this->getLanguageInstance()->getMessage('page_register_title')); 00104 00105 // ... and all variables. This should be merged together in a pattern 00106 // to make things easier. A cache mechanism should be added between 00107 // these two calls to cache compiled templates. 00108 $templateInstance->compileVariables(); 00109 00110 // Get the content back from the template engine and put it in response class 00111 $templateInstance->transferToResponse($responseInstance); 00112 } 00113 00121 public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) { 00122 // Empty class 00123 } 00124 } 00125 00126 // [EOF] 00127 ?>
1.5.6