@@ -49,13 +49,11 @@ public function implementedEvents()
4949 */
5050 public function beforeRender (Event $ event )
5151 {
52- $ controller = $ event ->subject ();
53-
54- if (!$ this ->isPaginatedApiRequest ($ controller )) {
52+ if (!$ this ->isPaginatedApiRequest ()) {
5553 return ;
5654 }
5755
58- $ this ->pagingInfo = $ controller ->request ->params ['paging ' ][$ controller ->name ];
56+ $ this ->pagingInfo = $ this ->request ->params ['paging ' ][$ event -> subject () ->name ];
5957 $ config = $ this ->config ();
6058
6159 if (!empty ($ config ['aliases ' ])) {
@@ -66,8 +64,8 @@ public function beforeRender(Event $event)
6664 $ this ->setVisibility ();
6765 }
6866
69- $ controller ->set ($ config ['key ' ], $ this ->pagingInfo );
70- $ controller ->viewVars ['_serialize ' ][] = $ config ['key ' ];
67+ $ event -> subject () ->set ($ config ['key ' ], $ this ->pagingInfo );
68+ $ event -> subject () ->viewVars ['_serialize ' ][] = $ config ['key ' ];
7169 }
7270
7371 /**
@@ -104,14 +102,12 @@ protected function setVisibility()
104102 * Checks whether the current request is a JSON or XML request with
105103 * pagination.
106104 *
107- * @param \Cake\Controller\Controller $controller A reference to the
108- * instantiating controller object
109105 * @return bool True if JSON or XML with paging, otherwise false.
110106 */
111- protected function isPaginatedApiRequest (Controller $ controller )
107+ protected function isPaginatedApiRequest ()
112108 {
113- if (isset ($ controller ->request ->params ['paging ' ]) &&
114- $ controller ->request ->is (['json ' , 'xml ' ])
109+ if (isset ($ this ->request ->params ['paging ' ]) &&
110+ $ this ->request ->is (['json ' , 'xml ' ])
115111 ) {
116112 return true ;
117113 }
0 commit comments