[ 'type' => 'integer', ], ]; } function __construct($scenario = 'create') { parent::__construct($scenario); $this->_random_seed = mt_rand(0, 1000000); } /** * @return string */ static function getClass_name() { return __CLASS__; } function get_setting() { return [$this->seed, $this->_random_seed]; } } class FooBar { private $_models = []; function __construct() { $count = mt_rand(50, 100); for ($i = 0; $i < $count; $i++) { $model = new TestModel(); $model->seed = mt_rand(0, 1000000); $this->_models[] = $model; } } /** * @return SModelStream */ function get_stream() { $fenrir = $this; $get_models = function ($offset, $count, $order, $select) use ($fenrir) { $ret = []; for ($real_offset = $offset; $real_offset < min($offset + $count, count($fenrir->_models)); $real_offset++) { $ret[] = $fenrir->_models[$real_offset]; } return $ret; }; $get_count = function () use ($fenrir) { return count($fenrir->_models); }; $stream = new SModelStream([ 'get_models' => $get_models, 'get_count' => $get_count, ]); return $stream; } } /** * Class TestModel */ class TestRecord extends SDBRecord { /** * @return string */ static function getTable_name() { return 'ascet_test'; } /** * @return string */ static function getClass_name() { return __CLASS__; } } echo '