Backend\Behaviors\ImportExportController
Overview
ImportExportController adds features for importing and exporting data.
This behavior is implemented in the controller like so:
public $implement = [
\Backend\Behaviors\ImportExportController::class,
];
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.
Extends
Public Properties
public Model $importModel
public array $importColumns
importColumns configuration.
public Model $exportModel
public array $exportColumns
exportColumns configuration.
Show inherited public properties
Inherited Public Properties
- $extendableStaticCalledClass - is the calling class when using a static method. (defined in October\Rain\Extension\ExtensionBase)
- $assetPath - specifies the relative path to the asset directory. (defined in Backend\Classes\ControllerBehavior)
- $assetUrlPath - specifies the public path to the asset directory. (defined in Backend\Classes\ControllerBehavior)
- $vars - is a list of variables to pass to the page. (defined in Backend\Classes\ControllerBehavior)
- $layout - to use for the view. (defined in Backend\Classes\ControllerBehavior)
- $suppressLayout - prevents the use of a layout. (defined in Backend\Classes\ControllerBehavior)
Protected Properties
protected $requiredProperties
requiredProperties that must exist in the controller using this behavior.
protected array $requiredConfig
requiredConfig values that must exist when applying the primary config file.
protected array $actions
actions visible in context of the controller
protected Backend\Classes\WidgetBase $importUploadFormWidget
importUploadFormWidget reference to the widget used for uploading import file.
protected Backend\Classes\WidgetBase $importOptionsFormWidget
importOptionsFormWidget reference to the widget used for specifying import options.
protected string $exportFileName
exportFileName used for export output.
protected Backend\Classes\WidgetBase $exportFormatFormWidget
exportFormatFormWidget reference to the widget used for standard export options.
protected Backend\Classes\WidgetBase $exportOptionsFormWidget
exportOptionsFormWidget reference to the widget used for custom export options.
Show inherited protected properties
Inherited Protected Properties
- $config - supplied. (defined in Backend\Classes\ControllerBehavior)
- $controller - reference. (defined in Backend\Classes\ControllerBehavior)
- $extensionHidden - are properties and methods that cannot be accessed. (defined in October\Rain\Extension\ExtensionBase)
- $assets - Collection of assets to display in the layout. (defined in Backend\Classes\ControllerBehavior)
- $assetBundles - Collection of combined and prioritized assets. (defined in Backend\Classes\ControllerBehavior)
- $assetDefaults - is the default attributes for assets. (defined in Backend\Classes\ControllerBehavior)
- $configPath - specifies a path to the config directory. (defined in Backend\Classes\ControllerBehavior)
- $viewPath - specifies a path to the views directory. (defined in Backend\Classes\ControllerBehavior)
- $layoutPath - specifies a path to the layout directory. (defined in Backend\Classes\ControllerBehavior)
- $viewPathGuessCache - remembers path guesses for performance. (defined in Backend\Classes\ControllerBehavior)
Public Methods
public __construct()
public __construct(Backend\Classes\Controller $controller): void
__construct the behavior
public actionImport()
public actionImport(): void
actionImport handles the import action logic
public actionImportLoadColumnSampleForm()
public actionImportLoadColumnSampleForm(): void
public beforeDisplay()
public beforeDisplay(): void
beforeDisplay fires before the page is displayed and AJAX is executed.
public beforeDisplayExport()
public beforeDisplayExport(): void
beforeDisplayExport loads the export form widgets
public beforeDisplayImport()
public beforeDisplayImport(): void
beforeDisplayImport loads the import form widgets
public download()
public download($name, $outputName = null): void
download action
public export()
public export(): void
export action
public exportFromList()
public exportFromList(string $definition = null, array $options = []): void
exportFromList outputs the list results as a CSV export.
public exportGetModel()
public exportGetModel(): void
public exportRender()
public exportRender(): void
public import()
public import(): void
import action
public importExportExtendColumns()
public importExportExtendColumns($columns, $context = null): void
public importExportExtendModel()
public importExportExtendModel(Model $model): Model
public importExportGetFileName()
public importExportGetFileName(): string
public importExportMakePartial()
public importExportMakePartial(
string $partial,
array $params = []
): string
importExportMakePartial controller accessor for making partials within this behavior.
public importGetModel()
public importGetModel(): void
public importIsColumnRequired()
public importIsColumnRequired($columnName): void
public importRender()
public importRender(): void
public onExport()
public onExport(): void
public onExportLoadForm()
public onExportLoadForm(): void
public onImport()
public onImport(): void
public onImportLoadColumnSampleForm()
public onImportLoadColumnSampleForm(): void
public onImportLoadForm()
public onImportLoadForm(): void
public prepareExportVars()
public prepareExportVars(): void
prepareExportVars for the view data.
public prepareImportVars()
public prepareImportVars(): void
prepareImportVars for the view data.
Inherited Public Methods
- addCss() - includes a StyleSheet asset to the asset list. (defined in Backend\Classes\ControllerBehavior)
- addCssBundle() - includes a CSS asset to the bundled combiner pipeline. (defined in Backend\Classes\ControllerBehavior)
- addJs() - includes a JavaScript asset to the asset list. (defined in Backend\Classes\ControllerBehavior)
- addJsBundle() - includes a JS asset to the bundled combiner pipeline. (defined in Backend\Classes\ControllerBehavior)
- addRss() - adds an RSS link asset to the asset list. Call $this->makeAssets(). (defined in Backend\Classes\ControllerBehavior)
- addViewPath() - prepends a path on the available view path locations. (defined in Backend\Classes\ControllerBehavior)
- combineAssets() - runs asset paths through the Asset Combiner. (defined in Backend\Classes\ControllerBehavior)
- extend() - this class with a closure. (defined in October\Rain\Extension\ExtensionBase)
- extensionApplyInitCallbacks() - (defined in October\Rain\Extension\ExtensionBase)
- extensionExtendCallback() - is a helper method for
::extend()static method. (defined in October\Rain\Extension\ExtensionBase) - extensionIsHiddenMethod() - (defined in October\Rain\Extension\ExtensionBase)
- extensionIsHiddenProperty() - (defined in October\Rain\Extension\ExtensionBase)
- flushAssets() - disables the use, and subsequent broadcast, of assets. This is useful. (defined in Backend\Classes\ControllerBehavior)
- getAssetPath() - locates a file based on it's definition. If the file starts with. (defined in Backend\Classes\ControllerBehavior)
- getAssetPaths() - returns an array of all registered asset paths. (defined in Backend\Classes\ControllerBehavior)
- getAssetPathsWithAttributes() - returns an array of all registered asset paths. (defined in Backend\Classes\ControllerBehavior)
- getCalledExtensionClass() - (defined in October\Rain\Extension\ExtensionBase)
- getConfig() - is a safe accessor for configuration values. (defined in Backend\Classes\ControllerBehavior)
- getConfigPath() - locates a file based on it's definition. If the file starts with. (defined in Backend\Classes\ControllerBehavior)
- getViewPath() - locates a file based on its definition. The file name can be prefixed. (defined in Backend\Classes\ControllerBehavior)
- getViewPaths() - returns the active view path locations. (defined in Backend\Classes\ControllerBehavior)
- getWidget() - (defined in Backend\Classes\ControllerBehavior)
- guessConfigPath() - guesses the package path for the called class. (defined in Backend\Classes\ControllerBehavior)
- guessConfigPathFrom() - guesses the package path from a specified class. (defined in Backend\Classes\ControllerBehavior)
- guessViewPath() - guesses the package path for the called class. (defined in Backend\Classes\ControllerBehavior)
- guessViewPathFrom() - guesses the package path from a specified class, including. (defined in Backend\Classes\ControllerBehavior)
- hasAssetsDefined() - returns true if assets any have been added. (defined in Backend\Classes\ControllerBehavior)
- localMakeFileContents() - makeFileContents includes a file path using output buffering. (defined in Backend\Classes\ControllerBehavior)
- makeAssets() - outputs
<link>and<script>tags to load assets previously added with addJs and addCss method calls. (defined in Backend\Classes\ControllerBehavior) - makeConfig() - reads the contents of the supplied file and applies it to this object. (defined in Backend\Classes\ControllerBehavior)
- makeConfigFromArray() - makes a config object from an array, making the first. (defined in Backend\Classes\ControllerBehavior)
- makeFileContents() - makes all views in context of the controller, not the behavior. (defined in Backend\Classes\ControllerBehavior)
- makeFormWidget() - object with the supplied form field and widget configuration. (defined in Backend\Classes\ControllerBehavior)
- makeLayout() - renders a layout. (defined in Backend\Classes\ControllerBehavior)
- makeLayoutPartial() - renders a layout partial. (defined in Backend\Classes\ControllerBehavior)
- makePartial() - renders a partial file contents located in the views folder. (defined in Backend\Classes\ControllerBehavior)
- makeView() - loads a view with the name specified. Applies layout if its name is provided. (defined in Backend\Classes\ControllerBehavior)
- makeViewContent() - renders supplied contents inside a layout. (defined in Backend\Classes\ControllerBehavior)
- makeWidget() - object with the supplied configuration file. (defined in Backend\Classes\ControllerBehavior)
- mergeConfig() - merges two configuration sources, either prepared or not, and returns. (defined in Backend\Classes\ControllerBehavior)
- resetSession() - Resets all session data related to this widget. (defined in Backend\Classes\ControllerBehavior)
- setConfig() - sets the configuration values. (defined in Backend\Classes\ControllerBehavior)
Protected Methods
protected actionExport()
protected actionExport(): void
actionExport handles the export action logic
protected checkPermissionsForType()
protected checkPermissionsForType($type): void
checkPermissionsForType checks to see if the import/export is controlled by permissions and if the logged in user has permissions.
protected checkRequiredImportColumns()
protected checkRequiredImportColumns(): void
protected checkUseListExportMode()
protected checkUseListExportMode(): void
protected createCsvReader()
protected createCsvReader($path): League\Csv\Reader
createCsvReader creates a new CSV reader with options selected by the user
protected exportFromListAsCsv()
protected exportFromListAsCsv($widget, $options): string
protected exportFromListAsJson()
protected exportFromListAsJson($widget, $options): string
protected filterImportColumnMatches()
protected filterImportColumnMatches($matches): array
filterImportColumnMatches rejects any undeclared columns
protected getExportColumns()
protected getExportColumns(): void
protected getFormatOptionsForModel()
protected getFormatOptionsForModel(): array
getFormatOptionsForModel returns the file format options used by models.
protected getFormatOptionsForPost()
protected getFormatOptionsForPost(): array
getFormatOptionsForPost returns the file format options from postback. This method can be used to define presets.
protected getImportDbColumns()
protected getImportDbColumns(): void
protected getImportFileColumns()
protected getImportFileColumns(): void
protected getImportFileColumnsFromCsv()
protected getImportFileColumnsFromCsv($path): void
getImportFileColumnsFromCsv path
protected getImportFileColumnsFromJson()
protected getImportFileColumnsFromJson($path): void
protected getImportFilePath()
protected getImportFilePath(): void
protected getImportSampleColumnsFromCsv()
protected getImportSampleColumnsFromCsv($path, $columnIndex): void
protected getImportSampleColumnsFromJson()
protected getImportSampleColumnsFromJson($path, $columnIndex): void
protected getImportSourceIndexOffset()
protected getImportSourceIndexOffset(bool $firstRowTitles): int
getImportSourceIndexOffset to add to the reported row number in status messages
protected getModelForType()
protected getModelForType($type): void
protected getRedirectUrlForType()
protected getRedirectUrlForType($type = null): void
protected isCustomFileFormat()
protected isCustomFileFormat(): void
isCustomFileFormat returns true if the process is using a custom format
via customJson or otherwise.
protected makeExportFileName()
protected makeExportFileName($mode = 'json'): void
protected makeExportFormatFormWidget()
protected makeExportFormatFormWidget(): void
protected makeExportOptionsFormWidget()
protected makeExportOptionsFormWidget(): void
protected makeImportOptionsFormWidget()
protected makeImportOptionsFormWidget(): void
protected makeImportUploadFormWidget()
protected makeImportUploadFormWidget(): void
protected makeListColumns()
protected makeListColumns($config, $model): void
protected makeOptionsFormWidgetForType()
protected makeOptionsFormWidgetForType($type): void
protected processExportColumnsFromPost()
protected processExportColumnsFromPost(): void
Show inherited protected methods
Inherited Protected Methods
- combineBundledAssets() - spins over every bundle definition and combines them to an asset. (defined in Backend\Classes\ControllerBehavior)
- controllerMethodExists() - (defined in Backend\Classes\ControllerBehavior)
- extensionHideMethod() - (defined in October\Rain\Extension\ExtensionBase)
- extensionHideProperty() - (defined in October\Rain\Extension\ExtensionBase)
- getAssetEntryBuildPath() - is an internal marker that returns the asset path. (defined in Backend\Classes\ControllerBehavior)
- getAssetScheme() - is an internal helper to get the asset scheme. (defined in Backend\Classes\ControllerBehavior)
- getConfigValueFrom() - will apply the config getter convention. (defined in Backend\Classes\ControllerBehavior)
- getLocalPath() - converts a relative path to a local path. (defined in Backend\Classes\ControllerBehavior)
- getSession() - Retrieves a widget related key/value pair from session data. (defined in Backend\Classes\ControllerBehavior)
- handleViewException() - handles a view exception. (defined in Backend\Classes\ControllerBehavior)
- hideAction() - protects a public method from being available as an controller action. (defined in Backend\Classes\ControllerBehavior)
- makeSessionId() - Returns a unique session identifier for this widget and controller action. (defined in Backend\Classes\ControllerBehavior)
- processAssetAttributes() - (defined in Backend\Classes\ControllerBehavior)
- putSession() - Saves a widget related key/value pair in to session data. (defined in Backend\Classes\ControllerBehavior)
- readSessionStore() - Reads the widget session store, preferring JSON and falling back to. (defined in Backend\Classes\ControllerBehavior)
- removeDuplicateAssets() - removes duplicate and global assets from the entire collection. (defined in Backend\Classes\ControllerBehavior)
- renderAssetAttributes() - takes an asset definition and returns the necessary HTML output. (defined in Backend\Classes\ControllerBehavior)