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 (opens new window)

# Public Methods

Method Description
displayName() Returns the display name of this class.
export() Creates the export data for elements fetched with the given element query.
extraFields() (opens new window) Returns the list of additional fields that can be returned by toArray() (opens new window) in addition to those listed in fields() (opens new window).
fields() (opens new window) Returns the list of fields that should be returned by default by toArray() (opens new window) when no specific fields are specified.
getFilename() Returns the filename that the export file should have.
instance() (opens new window) Returns static class instance, which can be used to obtain meta information.
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.
toArray() (opens new window) Converts the object into an array.

# 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:

Otherwise, a string or resource could also be returned.

View source (opens new window)

Arguments

Returns

array (opens new window), string (opens new window), callable (opens new window), resource (opens new window)

# 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 (opens new window)

Returns

string (opens new window)

# isFormattable()

Since
3.6.0

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

View source (opens new window)

Returns

boolean (opens new window)

# setElementType()

Sets the element type on the exporter.

View source (opens new window)

Arguments