HarvesterCommand
extends Command
in package
Uses
WriterAwareTrait
OAI-PMH Harvest Tool (Symfony Console Command)
Tags
Table of Contents
- $client : Client
- HTTP client
- $defaultName : string
- The name of the command
- $factory : HarvesterFactory
- Harvester factory
- $harvestRoot : string
- Root directory for harvesting
- $outputWriter : WriterInterface
- Writer helper
- $silent : bool
- Silent mode
- __construct() : mixed
- Constructor
- setOutputWriter() : void
- Set an object to accept console output messages.
- configure() : void
- Configure the command.
- execute() : int
- Run the command.
- getHarvestRoot() : string
- Get the target directory for writing harvested files.
- getHttpClient() : Client
- Get an HTTP client.
- getSettings() : array<string|int, mixed>|bool
- Load the harvest settings. Return false on error.
- getSettingsFromIni() : array<string|int, mixed>|bool
- Load configuration from an .ini file (or return false on error)
- harvestSingleRepository() : void
- Harvest a single repository.
- updateSettingsWithConsoleOptions() : array<string|int, mixed>
- Use command-line switches to add/override settings found in the .ini file, if necessary.
- write() : void
- Write a string to the console output writer (if set).
- writeLine() : void
- Write a string w/newline to the console output writer (if set).
Properties
$client
HTTP client
protected
Client
$client
$defaultName
The name of the command
protected
static string
$defaultName
= 'harvest/harvest_oai'
$factory
Harvester factory
protected
HarvesterFactory
$factory
$harvestRoot
Root directory for harvesting
protected
string
$harvestRoot
$outputWriter
Writer helper
protected
WriterInterface
$outputWriter
= null
$silent
Silent mode
protected
bool
$silent
Methods
__construct()
Constructor
public
__construct([Client $client = null ][, string $harvestRoot = null ][, HarvesterFactory $factory = null ][, bool $silent = false ][, string|null $name = null ]) : mixed
Parameters
- $client : Client = null
-
HTTP client (omit for default)
- $harvestRoot : string = null
-
Root directory for harvesting (omit for default)
- $factory : HarvesterFactory = null
-
Harvester factory (omit for default)
- $silent : bool = false
-
Should we suppress output?
- $name : string|null = null
-
The name of the command; passing null means it must be set in configure()
Return values
mixed —setOutputWriter()
Set an object to accept console output messages.
public
setOutputWriter(WriterInterface $writer) : void
Parameters
- $writer : WriterInterface
-
Writer object
Return values
void —configure()
Configure the command.
protected
configure() : void
Tags
Return values
void —execute()
Run the command.
protected
execute(InputInterface $input, OutputInterface $output) : int
Parameters
- $input : InputInterface
-
Input object
- $output : OutputInterface
-
Output object
Return values
int —0 for success
getHarvestRoot()
Get the target directory for writing harvested files.
protected
getHarvestRoot() : string
Return values
string —getHttpClient()
Get an HTTP client.
protected
getHttpClient() : Client
Return values
Client —getSettings()
Load the harvest settings. Return false on error.
protected
getSettings(InputInterface $input) : array<string|int, mixed>|bool
Parameters
- $input : InputInterface
-
Input object
Return values
array<string|int, mixed>|bool —getSettingsFromIni()
Load configuration from an .ini file (or return false on error)
protected
getSettingsFromIni(string $ini, string|bool $section) : array<string|int, mixed>|bool
Parameters
- $ini : string
-
Configuration file to load
- $section : string|bool
-
Section of .ini to load (or false for all)
Return values
array<string|int, mixed>|bool —harvestSingleRepository()
Harvest a single repository.
protected
harvestSingleRepository(InputInterface $input, OutputInterface $output, string $target, array<string|int, mixed> $settings) : void
Parameters
- $input : InputInterface
-
Input object
- $output : OutputInterface
-
Output object
- $target : string
-
Name of repo (used for target directory)
- $settings : array<string|int, mixed>
-
Settings for the harvester.
Tags
Return values
void —updateSettingsWithConsoleOptions()
Use command-line switches to add/override settings found in the .ini file, if necessary.
protected
updateSettingsWithConsoleOptions(InputInterface $input, array<string|int, mixed> $settings) : array<string|int, mixed>
Parameters
- $input : InputInterface
-
Input object
- $settings : array<string|int, mixed>
-
Incoming settings
Return values
array<string|int, mixed> —write()
Write a string to the console output writer (if set).
protected
write(string $str) : void
Parameters
- $str : string
-
String to write.
Return values
void —writeLine()
Write a string w/newline to the console output writer (if set).
protected
writeLine(string $str) : void
Parameters
- $str : string
-
String to write.