class UserImport extendsImport

Properties

protectedstring $path Path to the directory with the import files. from Import
protectedCollection $importUsers Caches the decoded user import file.

Methods

__construct(string$path)

Create a new instance.

from Import
bool
filesMatch()

Check if this import matches to the given import files.

from Import
validateFiles()

Check if the files of this import are valid.

from Import
array
expectedFiles()

The files expected by this import.

array
files()

Get the basename of each file of this import.

from Import
validateFile(string$basename)

Validate a file of this import.

expectKeysInJson(string$file,array$expectation,bool$array =true)

Validates a JSON file to contain an array of objects, each of which has all the expected keys.

from Import
expectColumnsInCsv(string$file,array$expectation)

Validates a CSV file to contain the expected columns.

from Import
Collection
collectJson(string$file)

Read a JSON file containing an array and wrap it in a Laravel collection.

from Import
array
perform(array$only =null)

Perform the import.

Collection
getImportUsers()

Get the contents of the user import file.

Collection
getUserImportCandidates()

Get users that can be imported.

Collection
getConflicts()

Get import users whose email address matches with an existing user but the UUID doesn't.

Details

inImportat line23
__construct(string$path)

Create a new instance.

Parameters

string $path Path to the directory with the import files.

inImportat line33
bool filesMatch()

Check if this import matches to the given import files.

Return Value

bool

inImportat line48
validateFiles()

Check if the files of this import are valid.

Exceptions

Exception If any of the import files is invalid.

at line99
protectedarray expectedFiles()

The files expected by this import.

Return Value

array

inImportat line70
protectedarray files()

Get the basename of each file of this import.

Return Value

array

at line107
protected validateFile(string$basename)

Validate a file of this import.

Parameters

string $basename Basename of the file.

Exceptions

Exception If the file is invalid.

inImportat line98
protected expectKeysInJson(string$file,array$expectation,bool$array =true)

Validates a JSON file to contain an array of objects, each of which has all the expected keys.

Parameters

string $file File name under $this->path
array $expectation Expected keys.
bool $array Specifies if the file to validate contains an array or not.

Exceptions

Exception If keys are missing.

inImportat line124
protected expectColumnsInCsv(string$file,array$expectation)

Validates a CSV file to contain the expected columns.

Parameters

string $file File name under $this->path
array $expectation Expected columns.

Exceptions

Exception If columns are missing.

inImportat line148
protectedCollection collectJson(string$file)

Read a JSON file containing an array and wrap it in a Laravel collection.

Parameters

string $file File name under $this->path

Return Value

Collection

at line26
array perform(array$only =null)

Perform the import.

Parameters

array $only IDs of the import candidates to limit the import to.

Return Value

array Maps external user IDs (from the import file) to user IDs of the database.

Exceptions

UnprocessableEntityHttpException If there are conflicts with the users that should be imported.

at line73
Collection getImportUsers()

Get the contents of the user import file.

Return Value

Collection

at line87
Collection getUserImportCandidates()

Get users that can be imported.

Return Value

Collection

at line129
protectedCollection getConflicts()

Get import users whose email address matches with an existing user but the UUID doesn't.

Return Value

Collection