Ok i am building up a controller class where i want a method to to be executed at the start and end of a function without this being typed into the function at all.
I have a controller that sets a value
Class IndicesController Extends \Cabbit\ControllerAction
{
// GET /indices
public static function indexAction()
{
self::$view->Indices = Index::all();
}
}
and a parent class controllerAction
namespace Cabbit;
Class ControllerAction
{
public static $view;
final function __construct()
{
self::$view = new View('index');
}
final function __destruct()
{
echo self::$view->display();
}
}
Now this results in
Listing Indices
Notice: Undefined variable: Indices in /Users/davidroy/Sites/workspace/cabbit/application/views/indices/index.phtml on line 9
Warning: Invalid argument supplied for foreach() in /Users/davidroy/Sites/workspace/cabbit/application/views/indices/index.phtml on line 9
Title Body
New
Listing Indices
Notice: Undefined variable: Indices in /Users/davidroy/Sites/workspace/cabbit/application/views/indices/index.phtml on line 9
Warning: Invalid argument supplied for foreach() in /Users/davidroy/Sites/workspace/cabbit/application/views/indices/index.phtml on line 9
Title Body
New
Listing Indices
Title Body
first This is a body Show Edit Destroy
second this is second Show Edit Destroy
New
Which as you can see did what i was looking for on the final result but for some reason also tried to call my view file to more times before hand. And if i got it working how i imagine it using without the extras it would accomplish one of my big aims for my framework.
Any ideas or suggestions to try.