GenerateCSVJob
class GenerateCSVJob extends AbstractQueuedJob (View source)
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 GridFieldQueuedExportButton.
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.
Properties
protected | stdClass | $jobData | from AbstractQueuedJob | |
protected | array | $messages | from AbstractQueuedJob | |
protected | int | $totalSteps | from AbstractQueuedJob | |
protected | int | $currentStep | from AbstractQueuedJob | |
protected | bool | $isComplete | from AbstractQueuedJob |
Methods
Sets a data object for persisting by adding its id and type to the serialised vars
Method for determining whether the job is finished - you may override it if there's more to it than just this
No description
Gets custom config settings to use when running the job.
Sets custom config settings to use when the job is run.
Convenience methods for setting and getting job data
This method is adapted from GridField->generateExportFileData()
Details
__construct()
Extensions can have a construct but don't have too.
Without a construct, it's impossible to create a job in the CMS
string
getTitle()
No description
protected
setObject(DataObject $object, string $name = 'Object')
Sets a data object for persisting by adding its id and type to the serialised vars
protected DataObject|void
getObject(string $name = 'Object')
No description
string
getSignature()
No description
protected string
randomSignature()
Generate a somewhat random signature
useful if you're want to make sure something is always added
getJobType()
No description
setup()
Performs setup tasks the first time this job is run.
This is only executed once for every job. If you want to run something on every job restart, use the prepareForRestart method.
prepareForRestart()
Run when an already setup job is being restarted.
process()
Generate export fields for CSV.
jobFinished()
Method for determining whether the job is finished - you may override it if there's more to it than just this
afterComplete()
Called when the job is determined to be 'complete'
getJobData()
No description
setJobData(int $totalSteps, int $currentStep, bool $isComplete, stdClass $jobData, array $messages)
No description
array|null
getCustomConfig()
Gets custom config settings to use when running the job.
setCustomConfig(array $config)
Sets custom config settings to use when the job is run.
addMessage(string $message, string $severity = 'INFO')
No description
__set(mixed $name, mixed $value)
Convenience methods for setting and getting job data
mixed
__get(mixed $name)
Retrieve some job data
setGridField(GridField $gridField)
No description
setSession($session)
No description
setColumns($columns)
No description
setSeparator($seperator)
No description
setIncludeHeader($includeHeader)
No description
protected
getOutputPath()
No description
protected GridField
getGridField()
No description
protected
outputHeader($gridField, $columns)
No description
protected
outputRows(GridField $gridField, array $columns, int $start, int $count)
This method is adapted from GridField->generateExportFileData()