class PublicLabelTreeImport extends Import

Properties

protected string $path

Path to the directory with the import files.

from  Import
protected Collection $importLabelTree

Caches the decoded label tree 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
perform()

Perform the import.

bool
treeExists()

Checks if the label tree of the import already exists.

Collection
getImportLabelTree()

Get the contents of the label tree import file.

importLabels(LabelTree $tree)

Import the labels of this import.

Details

in Import at line 23
__construct(string $path)

Create a new instance.

Parameters

string $path

Path to the directory with the import files.

in Import at line 33
bool filesMatch()

Check if this import matches to the given import files.

Return Value

bool

in Import at line 48
validateFiles()

Check if the files of this import are valid.

Exceptions

Exception

at line 70
protected array expectedFiles()

The files expected by this import.

Return Value

array

in Import at line 70
protected array files()

Get the basename of each file of this import.

Return Value

array

at line 81
protected validateFile(string $basename)

Validate a file of this import.

Parameters

string $basename

Basename of the file.

Exceptions

Exception

in Import at line 98
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

in Import at line 124
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

in Import at line 148
protected Collection 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 line 25
perform()

Perform the import.

at line 46
bool treeExists()

Checks if the label tree of the import already exists.

Return Value

bool

at line 58
protected Collection getImportLabelTree()

Get the contents of the label tree import file.

Return Value

Collection

at line 110
protected importLabels(LabelTree $tree)

Import the labels of this import.

Parameters

LabelTree $tree