grid = $grid; $this->grid->model()->usePaginate(false); } /** * Set export query name. * * @param $name */ public static function setQueryName($name) { static::$queryName = $name; } /** * Extends new exporter driver. * * @param $driver * @param $extend */ public static function extend($driver, $extend) { static::$drivers[$driver] = $extend; } /** * Resolve export driver. * * @param string $driver * * @return CsvExporter */ public function resolve($driver) { if ($driver instanceof Grid\Exporters\AbstractExporter) { return $driver->setGrid($this->grid); } return $this->getExporter($driver); } /** * Get export driver. * * @param string $driver * * @return CsvExporter */ protected function getExporter($driver) { if (!array_key_exists($driver, static::$drivers)) { return $this->getDefaultExporter(); } return new static::$drivers[$driver]($this->grid); } /** * Get default exporter. * * @return CsvExporter */ public function getDefaultExporter() { return new CsvExporter($this->grid); } /** * Format query for export url. * * @param int $scope * @param null $args * * @return array */ public static function formatExportQuery($scope = '', $args = null) { $query = ''; if ($scope == static::SCOPE_ALL) { $query = 'all'; } if ($scope == static::SCOPE_CURRENT_PAGE) { $query = "page:$args"; } if ($scope == static::SCOPE_SELECTED_ROWS) { $query = "selected:$args"; } return [static::$queryName => $query]; } }