Paginator Component can work with requestAction() #1436

Closed
wants to merge 5 commits into
from

1 participant

@zoghal

I'm not a lazy programmer. 3-hours hardly tried but did not succeed.
Please help me to implement the correct test.
I wanted to create like this test.: ( https://gist.github.com/zoghal/6032614
thanks

@ravage84 ravage84 commented on an outdated diff Jul 18, 2013
lib/Cake/Controller/Component/PaginatorComponent.php
@@ -238,7 +238,9 @@ public function paginate($object = null, $scope = array(), $whitelist = array())
(array)$this->Controller->request['paging'],
array($object->alias => $paging)
);
-
+ if(!empty($this->Controller->request->params['requested'])) {
@ravage84
CakePHP member
ravage84 added a line comment Jul 18, 2013

Code style error as reported by Travis:
https://travis-ci.org/cakephp/cakephp/jobs/9242562

241 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ravage84 ravage84 commented on an outdated diff Jul 18, 2013
lib/Cake/Controller/Component/PaginatorComponent.php
@@ -309,12 +311,16 @@ protected function _getObject($object) {
*/
public function mergeOptions($alias) {
$defaults = $this->getDefaults($alias);
+ $request = $this->Controller->request;
+ if(!empty($request->params['requested'])) {
@ravage84
CakePHP member
ravage84 added a line comment Jul 18, 2013

Code style error as reported by Travis:
https://travis-ci.org/cakephp/cakephp/jobs/9242562

315 | ERROR | Expected "if (...) {\n"; found "if(...) {\n"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@markstory markstory and 2 others commented on an outdated diff Jul 18, 2013
lib/Cake/Controller/Component/PaginatorComponent.php
@@ -309,12 +311,16 @@ protected function _getObject($object) {
*/
public function mergeOptions($alias) {
$defaults = $this->getDefaults($alias);
+ $request = $this->Controller->request;
+ if(!empty($request->params['requested'])) {
+ $request = Router::getRequest();
+ }
@markstory
CakePHP member
markstory added a line comment Jul 18, 2013

Couldn't you always use the controller request? That request object should be passed into the view as well.

@zoghal
zoghal added a line comment Jul 19, 2013

Requested by requestAction is generated, it does not handle any of the current controller parameters (named, pass). Actually creates a new request, and after receiving the request object is deleted.
So the Router :: getRequest () are used to access the requested controller

        if (is_string($url)) {
            $request = new CakeRequest($url);
        } elseif (is_array($url)) {
            $params = $url + array('pass' => array(), 'named' => array(), 'base' => false);
            $params = array_merge($params, $extra);
            $request = new CakeRequest(Router::reverse($params));
        }
        if (isset($data)) {
            $request->data = $data;
        }

        $dispatcher = new Dispatcher();
        $result = $dispatcher->dispatch($request, new CakeResponse(), $extra);
        Router::popRequest();
        return $result;
@markstory
CakePHP member
markstory added a line comment Jul 19, 2013

Yes this occurs because you're supposed to include the various passed/named parameters into the requestAction url. The current request parameters are intentionally not supposed to bleed into sub-requests.

It sounds like you were expecting parameters to bleed between requests. Which is the opposite of what should be happening.

@ADmad
CakePHP member
ADmad added a line comment Jul 19, 2013

Looking at the gist too it does seem he expects the named params to bleed through which is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@zoghal zoghal closed this Jul 24, 2013
@zoghal zoghal deleted the zoghal:reqestAction-Paginator branch Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment