Hi Rain!
Thank you very, very, very much for the answer! :)
1. Your solution doesn't work or I didn't understand you...
When I run your code I get error:
Notice: Undefined property: Loader::$my_session in \app\bootstrap.php ...
Fatal error: Call to a member function isGuest() on a non-object in \app\bootstrap.php on line 26
[Loader::load_model] method doesn't have second argument so the only think I can do is:
bootstrap.php
$session = $loader->load_model('Session');
$session->myMethod();
Now it's working, but I can't use this object in controllers and models. In that situation I will have to use singleton.
2. I'm looking for a solution to integrate ACL with your framework without checking entitlements in every controller's method:
BAD solution:
class My_Montroller extends Controller
{
public function method1()
{
$acl->isAllowed(My_Controller/method1')
{
//...
}else
{
//...
}// if
}// method
}// class
It seems to me that I've got idea, but I don't know how to implement it yet :)
bootstrap.php
//...
if( ! $acl->allowed($_SERVER['PHP_SELF'] )
{
// Here I must "force" on current controller to execute method [Controller::filter_on_access_denied] which I added to YOUR base controller class:
/*
Controller
{
//...
public function filter_on_access_denied()
{
$tpl = new View;
$tpl->assign('access_denied_message' => 'Bye bye! ;)'
$tpl->draw('acl/denied');
}
//...
}
*/
}
$loader->draw();
With this solution I'll have full control on every action in my application without adding any code. [acl/denied.html] template will be draw in the controller's load_area so user will see the announcement "in" page layout.
Any idea how to implement my "epic" solution? Is it generally possible? :)