VuFind API Documentation

Importer
in package

VuFind CSV importer configuration

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$configBaseDir  : string
Base path for loading .ini files
$serviceLocator  : ServiceLocatorInterface
Service locator
__construct()  : mixed
Constructor
save()  : string
Save a CSV file to the Solr index using the specified configuration.
adjustEncoding()  : array<string|int, mixed>
Fix the character encoding of a CSV line (if necessary).
applyCallbacks()  : array<string|int, string>
Recursively apply callback functions to a value.
collectValuesFromLine()  : array<string|int, mixed>
Collect field-specific values from a CSV input line. Returns an array mapping field name to value array.
getConfiguration()  : ImporterConfig
Load and set up the configuration object.
injectCallbackDependencies()  : void
Inject dependencies into the callback, if necessary.
processCallback()  : array<string|int, string>
Apply a single callback to a single value.
processConfiguration()  : ImporterConfig
Determine the list of fields that will be loaded.
processHeader()  : void
Process the header row, and generate a configuration.
processValues()  : array<string|int, string>
Process the values from a single column of a CSV.
writeData()  : string
Write a batch of JSON data to Solr.

Properties

$configBaseDir

Base path for loading .ini files

protected string $configBaseDir

$serviceLocator

Service locator

protected ServiceLocatorInterface $serviceLocator

Methods

__construct()

Constructor

public __construct(ServiceLocatorInterface $sm[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$sm : ServiceLocatorInterface

Service manager

$options : array<string|int, mixed> = []

Configuration options

Return values
mixed

save()

Save a CSV file to the Solr index using the specified configuration.

public save(string $csvFile, string $iniFile[, string $index = 'Solr' ][, bool $testMode = false ]) : string
Parameters
$csvFile : string

CSV file to load.

$iniFile : string

INI file.

$index : string = 'Solr'

Solr index to use.

$testMode : bool = false

Are we in test-only mode?

Tags
throws
Exception
Return values
string

Output for test mode

adjustEncoding()

Fix the character encoding of a CSV line (if necessary).

protected adjustEncoding(array<string|int, mixed> $line, string $encoding) : array<string|int, mixed>
Parameters
$line : array<string|int, mixed>

Input from CSV

$encoding : string

Encoding of $line

Return values
array<string|int, mixed>

Input re-encoded as UTF-8 (if not already in UTF-8)

applyCallbacks()

Recursively apply callback functions to a value.

protected applyCallbacks(string $value, array<string|int, string> $callbacks, array<string|int, mixed> $fieldValues) : array<string|int, string>
Parameters
$value : string

Value to process

$callbacks : array<string|int, string>

List of callback functions

$fieldValues : array<string|int, mixed>

Field values processed so far

Return values
array<string|int, string>

collectValuesFromLine()

Collect field-specific values from a CSV input line. Returns an array mapping field name to value array.

protected collectValuesFromLine(array<string|int, mixed> $line, ImporterConfig $config) : array<string|int, mixed>
Parameters
$line : array<string|int, mixed>

Line to process.

$config : ImporterConfig

Configuration object.

Return values
array<string|int, mixed>

getConfiguration()

Load and set up the configuration object.

protected getConfiguration(string $iniFile, resource $in) : ImporterConfig
Parameters
$iniFile : string

Name of .ini file to load

$in : resource

File handle to input file

Tags
throws
Exception
Return values
ImporterConfig

injectCallbackDependencies()

Inject dependencies into the callback, if necessary.

protected injectCallbackDependencies(string $callable) : void
Parameters
$callable : string

Callback function

Return values
void

processCallback()

Apply a single callback to a single value.

protected processCallback(string $callback, string $value, array<string|int, mixed> $fieldValues) : array<string|int, string>
Parameters
$callback : string

Callback string from config

$value : string

Value to process

$fieldValues : array<string|int, mixed>

Field values processed so far

Return values
array<string|int, string>

processConfiguration()

Determine the list of fields that will be loaded.

protected processConfiguration(array<string|int, mixed> $options, resource $in) : ImporterConfig
Parameters
$options : array<string|int, mixed>

Configuration

$in : resource

File handle to input file

Tags
throws
Exception
Return values
ImporterConfig

processHeader()

Process the header row, and generate a configuration.

protected processHeader(ImporterConfig $config, resource $in, string $mode) : void
Parameters
$config : ImporterConfig

Configuration to be updated

$in : resource

File handle to CSV

$mode : string

Header processing mode (fields/none/skip)

Return values
void

processValues()

Process the values from a single column of a CSV.

protected processValues(array<string|int, string> $values, array<string|int, mixed> $fieldConfig, array<string|int, mixed> $fieldValues) : array<string|int, string>
Parameters
$values : array<string|int, string>

Values to process

$fieldConfig : array<string|int, mixed>

Configuration to apply to values

$fieldValues : array<string|int, mixed>

Field values processed so far

Return values
array<string|int, string>

writeData()

Write a batch of JSON data to Solr.

protected writeData(array<string|int, mixed> $data, string $index, bool $testMode) : string
Parameters
$data : array<string|int, mixed>

Data to write

$index : string

Target Solr index

$testMode : bool

Are we in test mode?

Return values
string

Test mode output (if applicable) or empty string

Search results