@@ -49,13 +49,11 @@ public function implementedEvents()
49
49
*/
50
50
public function beforeRender (Event $ event )
51
51
{
52
- $ controller = $ event ->subject ();
53
-
54
- if (!$ this ->isPaginatedApiRequest ($ controller )) {
52
+ if (!$ this ->isPaginatedApiRequest ()) {
55
53
return ;
56
54
}
57
55
58
- $ this ->pagingInfo = $ controller ->request ->params ['paging ' ][$ controller ->name ];
56
+ $ this ->pagingInfo = $ this ->request ->params ['paging ' ][$ event -> subject () ->name ];
59
57
$ config = $ this ->config ();
60
58
61
59
if (!empty ($ config ['aliases ' ])) {
@@ -66,8 +64,8 @@ public function beforeRender(Event $event)
66
64
$ this ->setVisibility ();
67
65
}
68
66
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 ' ];
71
69
}
72
70
73
71
/**
@@ -104,14 +102,12 @@ protected function setVisibility()
104
102
* Checks whether the current request is a JSON or XML request with
105
103
* pagination.
106
104
*
107
- * @param \Cake\Controller\Controller $controller A reference to the
108
- * instantiating controller object
109
105
* @return bool True if JSON or XML with paging, otherwise false.
110
106
*/
111
- protected function isPaginatedApiRequest (Controller $ controller )
107
+ protected function isPaginatedApiRequest ()
112
108
{
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 ' ])
115
111
) {
116
112
return true ;
117
113
}
0 commit comments