0
votes

how to get the information in cakephp 2.3 which was in $this->params in cakephp 1.3 ?

So, the following array with the information of, say, controller, action, arguments, url etc.

Array
(
    [controller] => posts
    [action] => view
    [named] => Array
        (
        )

    [pass] => Array
        (
            [0] => 3
        )

    [plugin] => 
    [form] => Array
        (
        )

    [url] => Array
        (
            [url] => posts/view/3
        )

    [isAjax] => 
)

debugging $this->request and $this->params inside beforeFilter() in my AppController it just shows null for both of them.

Cake version 2.3.1

EDITED

Thanks

2

2 Answers

6
votes

From Cake 2.x you can retrieve:

  • POST data by $this->request->data
  • GET data by $this->params

Also note that you can access to the data through array

$this->request->data['variable'];

and through object:

$this->request->data('variable');
0
votes

I just left from cakephp 1.3

function __construct() {
    parent::__construct();
}

this part in my app controller, as soon as I removed it, $this->params returned the right thing.