|
Public URL
|
http://www.coderprofile.com/pinned-code/228/example-framework-implementation |
|
|
Language
|
PHP (Hypertext Preprocessor)
|
|
Expires
|
Never
|
|
Length
|
3,233 Characters (109 Lines)
|
|
Password
|
no password
|
|
|
<?php include $_SERVER['DOCUMENT_ROOT'] . '/../Ember/system/Ember.php'; /* * Variable initilization */ $gcTemplateCache = true; /* * Framework initilization */ Ember ::setPrereq( array('iPageInput' => Ember ::mciInterface, 'iPageProcess' => Ember::mciInterface, 'iPageDisplay' => Ember::mciInterface ) ); /* * Class Definition */ class Page implements iPageDisplay, iPageInput { protected $oPage; protected $oInput; protected $oOutput; public function __construct() { $this->oPage = Ember::init(); $this->oPage->loadIO('html', Ember::mciOutput); $this->oOutput = $this->oPage->Output['html']; $this->oOutput->setOperand('splash'); $this->oOutput->loadOperand(); $this->oOutput->setValue('title', 'Test
page'); } public function input() { $this->oPage->loadIO('form', Ember::mciInput); $this->oInput = $this->oPage->Input['form']; if ( $this->oOutput->getCacheStatus() == true ) { $this->oOutput->dumpCache(); } /* $oInput->sanitizeData(array('username' => array('minlen' => 3, 'maxlen' => 25, 'dataType' => iInput::mciString, ), 'password' => array('minlen' => 3, 'maxlen' => 25, 'dataType' => iInput::mciString, ), 'firstname' => array('minlen' => 3, 'maxlen' => 25, 'dataType' => Input::mciInteger, ), 'lastname' => array('minlen' => 3, 'maxlen' => 25, 'dataType' => Input::mciInteger, ) ) ); */ } public function display() { $this->oOutput->setValue('topics', array(array('title' => 'title 1', 'date' => '01/26/1990', 'replies' => '129'), array('title' => 'title 2', 'date' => '01/26/1990', 'replies' => '807') ) ); $this->oOutput->setValue('gen_time', (float ) microtime() - $iStart); $this->oOutput->dump(); } } /***** * Load Page *****/ try { Ember::setPages(new
Page); } catch ( EmberException $e ) { } catch ( Exception $e
) { } ?>
|
|
| Please login to post comments. |
|
|
It is not redundant. In the demonstration, indeed it may appear so, however consider what happens if I want to throw an exception from the end-implementation. I would be throwing an Exception, and not an EmberException.
As well, I find it good practice to catch Exception if there is a chance it MAY be thrown.
Additionally, so far as I know, every derived Exception class has to extend Exception. Correct me if I'm wrong, but I do do believe that is the case. It's all about the polymorphism.
Finally, I should note that I am further developing this implementation (of course). All that array crap is going to be garbage soon. Ugly, and resource intensive.
|
|
|
Does your EmberException extend Exception? If so, remove the catch( EmberException ) block as it is redundant and not needed. EmberException would be of type Exception. ;)
|
|
 |
Craige Leeder (20) Canada, Ontario |
|
|
Craige has 5 fans
become a fan |
|
 |
|
|
 |
|