PHP Class Craft\ImportService

Contains common import logic
Author: Bob Olde Hampsink ([email protected])
Inheritance: extends craft\BaseApplicationComponent
Datei anzeigen Open project: boboldehampsink/import Class Usage Examples

Public Properties

Property Type Description
$customOptionPaths array Custom
$log array Save log.

Public Methods

Method Description
columns ( string $file ) : array Read CSV columns.
data ( string $file ) : array Get CSV data.
debug ( array | object $settings, integer $history, integer $step )
finish ( array $settings, string $backup ) Finish importing.
getCustomOption ( string $fieldHandle ) : string Get path to fieldtype's custom
getService ( stirng $elementType ) : craft\IImportElementType | boolean Get service to use for importing.
onBeforeImportDelete ( craft\Event $event )
onImportFinish ( craft\Event $event )
onImportStart ( craft\Event $event )
prepForFieldType ( &$data, string $handle ) : mixed Prepare fields for fieldtypes.
row ( integer $row, array $data, array | object $settings ) Import row.
slugify ( string $slug ) : string Function that (almost) mimics Craft's inner slugify process.

Protected Methods

Method Description
_open ( string $file ) : array Special function that handles csv delimiter detection.
getNewTagModel ( ) : craft\TagModel
saveBackup ( array $settings, string $backup, craft\UserModel $currentUser ) : string

Private Methods

Method Description
prepAssetsFieldType ( string $data, craft\FieldModel $field ) : array
prepCategoriesFieldType ( string $data, craft\FieldModel $field ) : array
prepDropDownFieldType ( mixed $data, craft\FieldModel $field ) : mixed
prepEntriesFieldType ( string $data, craft\FieldModel $field ) : array
prepTagsFieldType ( string $data, craft\FieldModel $field ) : array
prepUsersFieldType ( string $data, craft\FieldModel $field ) : array
replaceOrDelete ( integer $row, array &$settings, craft\IImportElementType $service, array $fields ) : null | craft\BaseElementModel

Method Details

_open() protected method

Special function that handles csv delimiter detection.
protected _open ( string $file ) : array
$file string
return array

columns() public method

Read CSV columns.
public columns ( string $file ) : array
$file string
return array

data() public method

Get CSV data.
public data ( string $file ) : array
$file string
return array

debug() public method

public debug ( array | object $settings, integer $history, integer $step )
$settings array | object
$history integer
$step integer

finish() public method

Finish importing.
public finish ( array $settings, string $backup )
$settings array
$backup string

getCustomOption() public method

Get path to fieldtype's custom
public getCustomOption ( string $fieldHandle ) : string
$fieldHandle string
return string

getNewTagModel() protected method

protected getNewTagModel ( ) : craft\TagModel
return craft\TagModel

getService() public method

Get service to use for importing.
public getService ( stirng $elementType ) : craft\IImportElementType | boolean
$elementType stirng
return craft\IImportElementType | boolean

onBeforeImportDelete() public method

public onBeforeImportDelete ( craft\Event $event )
$event craft\Event

onImportFinish() public method

public onImportFinish ( craft\Event $event )
$event craft\Event

onImportStart() public method

public onImportStart ( craft\Event $event )
$event craft\Event

prepForFieldType() public method

Prepare fields for fieldtypes.
public prepForFieldType ( &$data, string $handle ) : mixed
$handle string
return mixed

row() public method

Import row.
public row ( integer $row, array $data, array | object $settings )
$row integer
$data array
$settings array | object

saveBackup() protected method

protected saveBackup ( array $settings, string $backup, craft\UserModel $currentUser ) : string
$settings array
$backup string
$currentUser craft\UserModel
return string Backup filename

slugify() public method

But... we allow forward slashes to stay, so we can create full uri's.
public slugify ( string $slug ) : string
$slug string
return string

Property Details

$customOptionPaths public_oe property

Custom
public array $customOptionPaths
return array

$log public_oe property

Save log.
public array $log
return array