
Originally Posted by
kyberfabrikken
It's a common confusion to identify model with a single class. In the MVC pattern, model is an abstract layer of your application.
It may be made up of several objects, as in an object-model, or by a few tablegateways. Either way, the view can certainly use data from several objects (or gateways)
Sure thing, I just wanted to know whether single View should be able to access multiple model objects.
Now lets take it to the code:
PHP Code:
<?php
class IndexCommand extends BaseCommand
{
public function execute()
{
$Message = new Message( new String( 'Blank Index Page' ), new String( 'Lorem ipsum dolor sit amet...' ) );
$this->addModel( new String( 'Identifier' ), $Message ); // is this any good?
$this->setViewHandle( new ViewHandle( new String( 'IndexSuccessView' ) ) );
}
}
?>
Then I can access it in View like this:
PHP Code:
<?php
$Message = $this->getModel( new String( 'Identifier' ) );
?>
What do you think about it? Is this any good? Or should I change it? How would you do it?
Bookmarks