Backend\Behaviors\ImportExportController

Source: ~/modules/backend/behaviors/ImportExportController.php

Extends:

Adds features for importing and exporting data.

This behavior is implemented in the controller like so:

public $implement = [
    'Backend.Behaviors.ImportExportController',
];

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

Parameters

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

public void export()

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

Outputs the list results as a CSV export.

Parameters
  • 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.

Parameters
  • string $partial
  • array $params

public void importGetModel()

public void importIsColumnRequired($columnName)
Parameters
  • $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.

Parameters
  • $type

protected void checkRequiredImportColumns()

protected void checkUseListExportMode()

protected CsvReader createCsvReader(string $path)

Create a new CSV reader with options selected by the user

Parameters
  • 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

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

protected void getModelForType($type)
Parameters
  • $type

protected void getRedirectUrlForType($type)
Parameters
  • $type

protected void makeExportFormatFormWidget()

protected void makeExportOptionsFormWidget()

protected void makeImportOptionsFormWidget()

protected void makeImportUploadFormWidget()

protected void makeListColumns($config)
Parameters
  • $config

protected void makeOptionsFormWidgetForType($type)
Parameters
  • $type

protected void processExportColumnsFromPost()

Show inherited protected methods

Inherited protected methods