Access $this->params and $this->data in components.
class LoginComponent extends Object {
/* */
public function login() {
pr($this->params);
pr($this->data);
}
}
I am using this in cake v1.2. I would like to know solution of this in v1.2 as well as v2.1. Please give me a suggestion.
Have a look at some components in your lib. I know this for Cake 2.x, not for 1.2.x. update: as mark mentioned in the comments, this works the same for the 1.x versions.
For example, when I open the
SecurityComponentI will find a function calledstartup(). This method defines itself as:as you can see, they
importthe Controller object. What you could right now is access the Controlelr methods and variables. Because as you might know: the$thiswhen calling$this->datarefers to theController.So, if I store this
$controllerin a protected variable called$_Controllerin my component, I can easily access the data and params like so:Have a look at this answer as well.