ptejada / f3-hmvc

13 stars 7 forks source link

HMVC requests #5

Open elvendor opened 11 years ago

elvendor commented 11 years ago

@ptejada, how about implementing HMVC requests with help of Base::call method? It would be great reusing controllers, models, views & lang files from module1 in module2. Here is how I'm thinking of it:

/* request method in BaseController.php */

protected function request($request, $params = array())
{
    /* The logic goes here */
}

/* use it in some module controller */

$users = $this->request('admin\controllers\User->userList()', array('sortby' => 'age'));

// or

if($this->request('auth\controllers\authorize->ckeck()'))
    echo 'you\'re logged!';
ptejada commented 11 years ago

Can be done but i'll have to look into it. My only concern is that the f3's Base class is a singleton so the hive is universal. Which means that calling a controller from another controller will stack paths of the modules. For example:

Calling module1\controllers\User->luserlist() will add app/module1/views folder to the hive UI variable.

Then calling module2\controllers\Group->add() will add app/module2/views folder to the hive UI variable, making the the UI value be app/;app/module1/views/;app/module2/views/.

I'll see what can be done