Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F95660591
PhutilBufferedIteratorExample.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 18, 03:05
Size
780 B
Mime Type
text/x-php
Expires
Fri, Dec 20, 03:05 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
23038528
Attached To
rPHU libphutil
PhutilBufferedIteratorExample.php
View Options
<?php
/**
* Example implementation and test case for @{class:PhutilBufferedIterator}.
*
* @group util
*/
final
class
PhutilBufferedIteratorExample
extends
PhutilBufferedIterator
{
private
$cursor
;
private
$data
;
protected
function
didRewind
()
{
$this
->
cursor
=
0
;
}
protected
function
loadPage
()
{
$result
=
$this
->
query
(
$this
->
cursor
,
$this
->
getPageSize
());
$this
->
cursor
+=
count
(
$result
);
return
$result
;
}
public
function
setExampleData
(
array
$data
)
{
$this
->
data
=
$data
;
}
private
function
query
(
$cursor
,
$limit
)
{
// NOTE: Normally you'd load or generate results from some external source
// here. Since this is an example, we just use a premade dataset.
return
array_slice
(
$this
->
data
,
$cursor
,
$limit
);
}
}
Event Timeline
Log In to Comment