fuel/core — pull request #1027 by s4wny (2012-06-16 20:01:22+00:00)
Title: Added 'set_global' to ViewModels. This allows to create much cleaner code

### An example ###

This change allows users to do like this:

In my controller I just want to do this:

return Response::forge(ViewModel::forge('template/index'));

And then in my ViewModel do this:

set_global('baseUrl', Uri::base(0));
$this->set_global('testImgLink', $this->baseUrl . 'image/' . 0 . '/'. $name); //Note: $this->baseUrl works!

//-------------------------------------------------
// The layout
//-------------------------------------------------

$this->header = View::forge('header');
$this->search = View::forge('search');
$this->imageList = View::forge('image/list');
$this->footer = View::forge('footer');
}
}

?>

__What I do: I load every part of my template in the ViewModel. This keeps the controllers and the view clean from irrelevant code. Hope you understand and accept this pull.__

Without this change I need too load everything in either the Controller or the View, that just feels... wrong.

Btw, I think it may would be a good idea to add every function from `classes\view.php` to `classess\viewModel.php`.