Can it be possible to track all the set variable by $this->set('variable_name', 'some_value')
in the controller's method itself.
Actually i have a method that call several other method and each sub method set the value to view. Now I am unable to track if the same key set twice in the main method or not.
example
function beforeFilter()
{
$this->set('key1', 'viable value');
}
function reqMethod()
{
$this->extendMethod1();
$this->extendMethod2();
$this->extendMethod3();
$this->extendMethod4();
$this->extendMethod5();
$this->extendMethod6();
// Want to track all set variable (key) here.
}
private function extendMethod1()
{
$this->set('key1', 'unknow value');
}
Here it may possible that key1 (by mistake) can be set to another method. Any help really be appreciated.
beforeFilter() executes functions that you NEED to be executed before any other action. Controller::beforeFilter() This function is executed before every action in the controller. It's a handy place to check for an active session or inspect user permissions. http://api.cakephp.org/2.3/class-Controller.html#_ ...
CakePHP's default layout is located at templates/layout/default. php. If you want to change the overall look of your application, then this is the right place to start, because controller-rendered view code is placed inside of the default layout when the page is rendered.
Use $this->params['controller'] to get the current controller.
compact() or set() in cakephp set() is the way to set values in your controller and get those values in your view file. Syntax of set is-> $this->set('variable','value')
Controller::set() just adds value(s) to the 'viewVars' property, so to debug all those variables, you'll only have to do this:
debug($this->viewVars);
You could have discovered this yourself, by looking inside the source?
view the source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With