[Solar-talk] Partials/Tiles/Elements/Components/Something
Rodrigo Moraes
rodrigo.moraes at gmail.com
Wed Nov 15 00:41:20 PST 2006
On 11/14/06, Paul M Jones wrote:
> > I would like to see the page controller as a property for
> > the app classes, so we can pass it along to "components" instead of
> > creating it over and over.
>
> This is an interesting idea; what do you think the implementation
> would look like?
The work is to create interfaces to access the page controller inside
the app and for the app inside the page controller. Properties would
need accessors or visibility changes, and some would be moved and
defined once, not in both classes. Hooks would belong to the app, and
not the page controller.
A page controller instance would be shared by app controllers as a
property along the way. App controllers would be defined inside the
page controllers after construction.
Skeleton examples:
Solar_App extends Solar_Base
-----------------------------------------------------
/**
*
* Solar_Controller_Page instance
*
* @var object
*
*/
protected $_page;
public function __construct($config = null)
{
parent::__construct();
// Build the Page Controller, it not yet.
if(!$this->_config['page_controller']) {
// "Solar_Controller_MyPage" is user defined; it is here
as an example.
$this->_config['page_controller'] =
Solar::factory('Solar_Controller_MyPage');
}
// Set the page controller.
$this->_page = $this->_config['page_controller'];
// Set the app for the page controller.
$this->_page->setApp($this);
// extended setup
$this->_setup();
}
public function __call($method, $args)
{
if(method_exists($this->_page, $method)) {
return call_user_func_array( array($this->_page, $method), $args );
//$this->_page->$method($args);
} else {
// throw exception
}
}
Solar_Controller_Page extends Solar_Base
-----------------------------------------------------
/**
*
* Solar_App instance
*
* @var object
*
*/
protected $_app;
public function setApp($app)
{
$this->_app = $app;
}
protected function _getActionMethod($action)
{
// [snip]
if (method_exists($this->_app, $word)) {
return $word;
} else {
// [snip]
}
It's a whole mechanism to think about, but perhaps this can give you a
better idea. The main purpose is to put the page controller "outside
of the app", as a property and not inherited.
thoughts?
rodrigo
---------------------------------------------------------------------
Solar has now a Community Wiki: solarphp.org
---------------------------------------------------------------------
Join the #solarphp IRC channel on freenode.org
---------------------------------------------------------------------
More information about the solar-talk
mailing list