PHP Class Craft\ImportService

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

Méthodes publiques

Свойство Type Description
$customOptionPaths array Custom
$log array Save log.

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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

Méthode 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 méthode

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

columns() public méthode

Read CSV columns.
public columns ( string $file ) : array
$file string
Résultat array

data() public méthode

Get CSV data.
public data ( string $file ) : array
$file string
Résultat array

debug() public méthode

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

finish() public méthode

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

getCustomOption() public méthode

Get path to fieldtype's custom
public getCustomOption ( string $fieldHandle ) : string
$fieldHandle string
Résultat string

getNewTagModel() protected méthode

protected getNewTagModel ( ) : craft\TagModel
Résultat craft\TagModel

getService() public méthode

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

onBeforeImportDelete() public méthode

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

onImportFinish() public méthode

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

onImportStart() public méthode

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

prepForFieldType() public méthode

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

row() public méthode

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

saveBackup() protected méthode

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

slugify() public méthode

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

Property Details

$customOptionPaths public_oe property

Custom
public array $customOptionPaths
Résultat array

$log public_oe property

Save log.
public array $log
Résultat array