File tree Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Expand file tree Collapse file tree 2 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -41,11 +41,15 @@ public function getById($id) {
41
41
* @return void
42
42
*/
43
43
protected function _getPageParams ($ start =0 , $ size =20 ) {
44
- $ params = array (
45
- 'ws.start ' => $ start ,
46
- 'ws.size ' => $ size ,
47
- );
48
- ksort ($ params );
44
+ if ($ start > 0 ) {
45
+ $ params = array (
46
+ 'ws.start ' => $ start ,
47
+ 'ws.size ' => $ size ,
48
+ );
49
+ ksort ($ params );
50
+ } else {
51
+ $ params = array ();
52
+ }
49
53
return $ params ;
50
54
}
51
55
@@ -64,6 +68,28 @@ protected function _type() {
64
68
return $ type ;
65
69
}
66
70
71
+ /**
72
+ * _calculatePageSize
73
+ *
74
+ * Calculates the page size of this collection based on the data in the
75
+ * next and prev links.
76
+ *
77
+ * @access protected
78
+ * @return integer
79
+ */
80
+ protected function _calculatePageSize () {
81
+ if (isset ($ this ->data ['next_collection_link ' ])) {
82
+ $ url = $ this ->data ['next_collection_link ' ];
83
+ $ urlParts = parse_url ($ url );
84
+ if (empty ($ urlParts ['query ' ])) return $ this ->pageSize ;
85
+ $ query = array ();
86
+ parse_str ($ urlParts ['query ' ], $ query );
87
+ if (empty ($ query ['ws_size ' ])) return $ this ->pageSize ;
88
+ $ this ->pageSize = $ query ['ws_size ' ];
89
+ }
90
+ return $ this ->pageSize ;
91
+ }
92
+
67
93
/**
68
94
* _loadPageForOffset
69
95
*
@@ -77,6 +103,7 @@ protected function _type() {
77
103
* @return void
78
104
*/
79
105
protected function _loadPageForOffset ($ offset , $ attempt =1 ) {
106
+ $ this ->_calculatePageSize ();
80
107
$ start = round ($ offset / $ this ->pageSize ) * $ this ->pageSize ;
81
108
$ params = $ this ->_getPageParams ($ start , $ this ->pageSize );
82
109
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ public function __get($value) {
73
73
if (in_array ($ value , $ this ->_privateData )) {
74
74
return null ;
75
75
}
76
- if (array_key_exists ($ value , $ this ->data )) {
76
+ if (! empty ( $ this -> data ) && array_key_exists ($ value , $ this ->data )) {
77
77
return $ this ->data [$ value ];
78
78
}
79
79
if ($ value == 'type ' ) return $ this ->_type ();
You can’t perform that action at this time.
0 commit comments