ImportSettingsDto
in package
FinalYes
Import settings. They exist in two instances and only one of them decides:
- the job settings (admin form) are the only source of truth,
<settings>from the file are only a proposal; the validator lists differences asinfolog lines so the admin can see them, adjust the job settings ineditand revalidate.
Table of Contents
Constants
- ACTION_SKIP : string = 'skip'
- ACTIONS : array<string|int, mixed> = [self::MODE_CREATE, self::MODE_UPDATE, self::MO...
- COLLECTION_MERGE : string = 'merge'
- COLLECTION_MODES : array<string|int, mixed> = [self::COLLECTION_MERGE, self::COLLECTION_REPLACE]
- COLLECTION_REPLACE : string = 'replace'
- MATCH_BY_CODE : string = 'code'
- MATCH_BY_EAN : string = 'ean'
- MATCH_BYS : array<string|int, mixed> = [self::MATCH_BY_CODE, self::MATCH_BY_EAN]
- MODE_CREATE : string = 'create'
- MODE_UPDATE : string = 'update'
- MODE_UPSERT : string = 'upsert'
- MODES : array<string|int, mixed> = [self::MODE_UPSERT, self::MODE_CREATE, self::MO...
Properties
- $autoCreateCategories : bool
- $autoCreateOptions : bool
- $autoCreateProducers : bool
- $collectionMode : string
- $defaultLang : string
- $matchBy : string
- $mode : string
- $stopOnError : bool
Methods
- __construct() : mixed
- diff() : array<string, array{file: string|bool, job: string|bool}>
- Returns keys in which the file `<settings>` differ from the job settings, as the base for `info` log lines (the job decides, but the admin should see the difference).
- fromArray() : self
- Builds settings from the shape stored on the job ({@see \App\Core\Base\Shared\Eshop\Models\Entities\ProductImport::$settings}) or collected from the file `<settings>`; a missing key falls back to the default.
- toArray() : array<string, string|bool>
- pickBool() : bool
- pickLang() : string
- pickString() : string
Constants
ACTION_SKIP
public
string
ACTION_SKIP
= 'skip'
ACTIONS
public
array<string|int, mixed>
ACTIONS
= [self::MODE_CREATE, self::MODE_UPDATE, self::MODE_UPSERT, self::ACTION_SKIP]
per-item override of the job mode
COLLECTION_MERGE
public
string
COLLECTION_MERGE
= 'merge'
COLLECTION_MODES
public
array<string|int, mixed>
COLLECTION_MODES
= [self::COLLECTION_MERGE, self::COLLECTION_REPLACE]
COLLECTION_REPLACE
public
string
COLLECTION_REPLACE
= 'replace'
MATCH_BY_CODE
public
string
MATCH_BY_CODE
= 'code'
MATCH_BY_EAN
public
string
MATCH_BY_EAN
= 'ean'
MATCH_BYS
public
array<string|int, mixed>
MATCH_BYS
= [self::MATCH_BY_CODE, self::MATCH_BY_EAN]
MODE_CREATE
public
string
MODE_CREATE
= 'create'
MODE_UPDATE
public
string
MODE_UPDATE
= 'update'
MODE_UPSERT
public
string
MODE_UPSERT
= 'upsert'
MODES
public
array<string|int, mixed>
MODES
= [self::MODE_UPSERT, self::MODE_CREATE, self::MODE_UPDATE]
Properties
$autoCreateCategories read-only
public
bool
$autoCreateCategories
= false
$autoCreateOptions read-only
public
bool
$autoCreateOptions
= false
$autoCreateProducers read-only
public
bool
$autoCreateProducers
= true
$collectionMode read-only
public
string
$collectionMode
= self::COLLECTION_MERGE
$defaultLang read-only
public
string
$defaultLang
= 'cs'
$matchBy read-only
public
string
$matchBy
= self::MATCH_BY_CODE
$mode read-only
public
string
$mode
= self::MODE_UPSERT
$stopOnError read-only
public
bool
$stopOnError
= false
Methods
__construct()
public
__construct([string $mode = self::MODE_UPSERT ][, string $matchBy = self::MATCH_BY_CODE ][, string $defaultLang = 'cs' ][, string $collectionMode = self::COLLECTION_MERGE ][, bool $autoCreateProducers = true ][, bool $autoCreateOptions = false ][, bool $autoCreateCategories = false ][, bool $stopOnError = false ]) : mixed
Parameters
- $mode : string = self::MODE_UPSERT
- $matchBy : string = self::MATCH_BY_CODE
- $defaultLang : string = 'cs'
- $collectionMode : string = self::COLLECTION_MERGE
- $autoCreateProducers : bool = true
- $autoCreateOptions : bool = false
- $autoCreateCategories : bool = false
- $stopOnError : bool = false
diff()
Returns keys in which the file `<settings>` differ from the job settings, as the base for `info` log lines (the job decides, but the admin should see the difference).
public
diff(self $other) : array<string, array{file: string|bool, job: string|bool}>
Parameters
- $other : self
Return values
array<string, array{file: string|bool, job: string|bool}>fromArray()
Builds settings from the shape stored on the job ({@see \App\Core\Base\Shared\Eshop\Models\Entities\ProductImport::$settings}) or collected from the file `<settings>`; a missing key falls back to the default.
public
static fromArray(array<string, mixed> $values) : self
Parameters
- $values : array<string, mixed>
Return values
selftoArray()
public
toArray() : array<string, string|bool>
Return values
array<string, string|bool>pickBool()
private
static pickBool(array<string, mixed> $values, string $key, bool $default) : bool
Parameters
- $values : array<string, mixed>
- $key : string
- $default : bool
Return values
boolpickLang()
private
static pickLang(array<string, mixed> $values) : string
Parameters
- $values : array<string, mixed>
Return values
stringpickString()
private
static pickString(array<string, mixed> $values, string $key, string $default, array<int, string> $allowed) : string
Parameters
- $values : array<string, mixed>
- $key : string
- $default : string
- $allowed : array<int, string>