SilverStripe\GridfieldQueuedExport\Jobs\GenerateCSVJob
Iteratively exports GridField data to a CSV file on disk, in order to support large exports.
The generated file can be downloaded by the user through a CMS UI provided in .
Simulates a request to the GridFieldQueuedExportButton controller to retrieve the GridField instance,
from which the original data context can be derived (as an {@link SS_List instance).
This is a necessary workaround due to the limitations on serialising GridField's data description logic.
While a DataList is serialisable, other SS_List instances might not be.
We'd also need to consider custom value transformations applied via GridField->customDataFields lambdas.
Relies on GridField being accessible in its original CMS controller context to the user
who triggered the export.
Synopsis
class GenerateCSVJob
extends AbstractQueuedJob
{
- // members
- private static integer $sync_sleep_seconds = 0;
- private static integer $chunk_size = 100;
- private static string $permission_mode = '0770';
- private static bool $ignore_umask = false;
- protected $writer;
- // methods
- public void __construct()
- public string getJobType()
- public string getTitle()
- public string getSignature()
- public void setGridField()
- public void setSession()
- public void setColumns()
- public void setSeparator()
- public void setIncludeHeader()
- protected void makeDir()
- protected void getOutputPath()
- protected Writer getCSVWriter()
- protected GridField getGridField()
- protected void outputHeader()
- protected void outputRows()
- public void setup()
- protected void initRequest()
- public void process()
Hierarchy
Extends
- Symbiote\QueuedJobs\Services\AbstractQueuedJob
Uses
- SilverStripe\Core\Config\Configurable
Members
private
- $chunk_size — int
- $ignore_umask — SilverStripe\GridfieldQueuedExport\Jobs\bool
- $permission_mode — string
- $sync_sleep_seconds
—
int
Optionally define the number of seconds to wait after the job has finished before marking it as complete.
protected
- $writer
Methods
protected
- getCSVWriter()
- getGridField()
- getOutputPath()
- initRequest() — Normally Director::handleRequest will register an HTTPRequest service (when routing via frontend controllers).
- makeDir()
- outputHeader()
- outputRows() — This method is adapted from GridField->generateExportFileData()
public
- __construct()
- getJobType()
- getSignature()
- getTitle()
- process() — Generate export fields for CSV.
- setColumns()
- setGridField()
- setIncludeHeader()
- setSeparator()
- setSession()
- setup()