/** * Class constructor * @param Media[] $rawData the data * @param array $config the component configuration (optional) */ public function __construct($rawData, $config = array()) { // Optionally apply pagination, unless it has been explicitly disabled $pagesize = Setting::getInteger('pagesize'); if (!isset($config['pagination'])) { $config['pagination'] = $pagesize ? array('pageSize' => $pagesize) : false; } // Determine the key field from the first item if (isset($rawData[0])) { $config['keyField'] = $rawData[0]->getIdField(); } parent::__construct($rawData, $config); }
public function __construct($response, $config = array()) { $this->response = $response; $matches = array(); foreach ($this->response['matches'] as $id => $data) { $match = new stdClass(); foreach ($data['attrs'] as $key => $value) { $match->{$key} = $value; } $match->id = $id; $match->model = ActiveRecord::model($match->model_id)->findByPk($match->object_id); $match->_weight = $data['weight']; $matches[$id] = $match; } parent::__construct($matches, $config); }