Adds features for importing and exporting data.

This behavior is implemented in the controller like so:

public $implement = [

public $importExportConfig = 'config_import_export.yaml';

The $importExportConfig property makes reference to the configuration values as either a YAML file, located in the controller view directory, or directly as a PHP array.

Public properties

public Model $importModel

Import model

public array $importColumns

Import column configuration.

public Model $exportModel

Export model

public array $exportColumns

Export column configuration.

Show inherited public properties

Inherited public properties

Protected properties

protected $requiredProperties

Properties that must exist in the controller using this behavior.

protected array $requiredConfig

Configuration values that must exist when applying the primary config file.

protected array $actions

Visible actions in context of the controller

protected Backend\Classes\WidgetBase $importUploadFormWidget

Reference to the widget used for uploading import file.

protected Backend\Classes\WidgetBase $importOptionsFormWidget

Reference to the widget used for specifying import options.

protected string $exportFileName

File name used for export output.

protected Backend\Classes\WidgetBase $exportFormatFormWidget

Reference to the widget used for standard export options.

protected Backend\Classes\WidgetBase $exportOptionsFormWidget

Reference to the widget used for custom export options.

Show inherited protected properties

Inherited protected properties

Public methods

public void __construct(Backend\Classes\Controller $controller)

Behavior constructor


public void download($name, $outputName=NULL)
  • $name
  • $outputName

public void export()

public void exportFromList(string $definition=NULL, array $options=array())

Outputs the list results as a CSV export.

  • string $definition
  • array $options

public void exportGetModel()

public void exportRender()

public void import()

public string importExportMakePartial(string $partial, array $params=array())

Controller accessor for making partials within this behavior.

  • string $partial
  • array $params

public void importGetModel()

public void importIsColumnRequired($columnName)
  • $columnName

public void importRender()

public void onExport()

public void onExportLoadForm()

public void onImport()

public void onImportLoadColumnSampleForm()

public void onImportLoadForm()

public void prepareExportVars()

Prepares the view data.

public void prepareImportVars()

Prepares the view data.

Show inherited public methods

Inherited public methods

Protected methods

protected View checkPermissionsForType($type)

Checks to see if the import/export is controlled by permissions and if the logged in user has permissions.

  • $type

protected void checkRequiredImportColumns()

protected void checkUseListExportMode()

protected CsvReader createCsvReader(string $path)

Create a new CSV reader with options selected by the user

  • string $path

protected void getExportColumns()

protected array getFormatOptionsFromPost()

Returns the file format options from postback. This method can be used to define presets.

protected void getImportDbColumns()

protected void getImportFileColumns()

protected void getImportFilePath()

protected int getImportSourceIndexOffset(bool $firstRowTitles)

Get the index offset to add to the reported row number in status messages

  • bool $firstRowTitles - Whether or not the first row contains column titles

protected void getModelForType($type)
  • $type

protected void getRedirectUrlForType($type)
  • $type

protected void makeExportFormatFormWidget()

protected void makeExportOptionsFormWidget()

protected void makeImportOptionsFormWidget()

protected void makeImportUploadFormWidget()

protected void makeListColumns($config)
  • $config

protected void makeOptionsFormWidgetForType($type)
  • $type

protected void processExportColumnsFromPost()

Show inherited protected methods

Inherited protected methods