Skip to content

ElementExporterInterface ​

Type
Interface
Namespace
craft\base
Extends
craft\base\ComponentInterface
Implemented by
craft\base\ElementExporter, craft\elements\exporters\Expanded, craft\elements\exporters\Raw
Since
3.4.0

ElementExporterInterface defines the common interface to be implemented by element exporter classes.

View source

Public Methods ​

MethodDescription
displayName()Returns the display name of this class.
export()Creates the export data for elements fetched with the given element query.
getFilename()Returns the filename that the export file should have.
isFormattable()Returns whether the response data can be formatted as CSV, JSON, or XML.
isSelectable()Returns whether the component should be selectable in component Type selects.
setElementType()Sets the element type on the exporter.

export() ​

Creates the export data for elements fetched with the given element query.

If isFormattable() returns true, then this must return one of the followings:

  • An array of arrays
  • A callable that returns an array of arrays
  • A generator function that yields arrays.

Otherwise, a string or resource could also be returned.

View source

Arguments ​

Returns ​

array, string, callable, resource

getFilename() ​

Returns the filename that the export file should have.

If the data is formattable, then a file extension will be added based on the selected format.

View source

Returns ​

string

isFormattable() ​

Since
3.6.0

Returns whether the response data can be formatted as CSV, JSON, or XML.

View source

Returns ​

boolean

setElementType() ​

Sets the element type on the exporter.

View source

Arguments ​