DocumentsCommandHarvest uses trait:short, trait:short, \oihana\models\traits\ListModelTrait, \Symfony\Component\Console\Command\LockableTrait, \oihana\commands\traits\UITrait
The documents harvest command helper.
Table of Contents
Properties
- $documents : Documents|null
- The DocumentsModel instance for data operations.
- $excludes : array<string|int, mixed>|mixed|null
- A list of properties to exclude during data manipulation operations like insert, update, replace, or upsert.
- $fields : array<string|int, mixed>
- The document's fields to display in tabular output.
- $removeKeys : array<string|int, mixed>|mixed|null
- A list of properties to remove during data manipulation operations like insert, update, replace, or upsert.
Methods
- assertDocuments() : void
- Asserts that the 'documents' property has been initialized.
- fetchDocuments() : array<string|int, mixed>
- Fetch all documents from the OpenEdge database.
- harvest() : int
- Harvest the documents from a ListModel and upsert it in the documents collection.
- initializeDocuments() : static
- Initializes the 'documents' property.
- outputDocuments() : void
- Renders a list of documents to the console output.
- upsert() : int
- Upsert a document in the collection.
Properties
$documents
The DocumentsModel instance for data operations.
public
Documents|null
$documents
$excludes
A list of properties to exclude during data manipulation operations like insert, update, replace, or upsert.
public
array<string|int, mixed>|mixed|null
$excludes
= null
$fields
The document's fields to display in tabular output.
public
array<string|int, mixed>
$fields
= [\org\schema\constants\Schema::_KEY, \org\schema\constants\Schema::NAME, \org\schema\constants\Schema::CREATED, \org\schema\constants\Schema::MODIFIED]
$removeKeys
A list of properties to remove during data manipulation operations like insert, update, replace, or upsert.
public
array<string|int, mixed>|mixed|null
$removeKeys
= null
Methods
assertDocuments()
Asserts that the 'documents' property has been initialized.
protected
assertDocuments() : void
Tags
fetchDocuments()
Fetch all documents from the OpenEdge database.
protected
fetchDocuments(OutputInterface $output[, Documents|null $ref = null ][, string $name = 'documents' ][, array<string|int, mixed> $init = [] ]) : array<string|int, mixed>
Parameters
- $output : OutputInterface
-
The console output instance.
- $ref : Documents|null = null
-
The optional Documents reference to use (default, use $this->documents)
- $name : string = 'documents'
-
The optional name of the documents (default "documents").
- $init : array<string|int, mixed> = []
-
An associative array of optional settings to define the query - Documents::list().
Tags
Return values
array<string|int, mixed>harvest()
Harvest the documents from a ListModel and upsert it in the documents collection.
protected
harvest(InputInterface $input, OutputInterface $output[, mixed|null $option = null ]) : int
Parameters
- $input : InputInterface
- $output : OutputInterface
- $option : mixed|null = null
Tags
Return values
int —0 if everything went fine, or an exit code
initializeDocuments()
Initializes the 'documents' property.
protected
initializeDocuments([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
This method attempts to find a service name in the '$init' array and uses the provided PSR container to retrieve the DocumentsModel instance.
Parameters
- $init : array<string|int, mixed> = []
-
An array of initialization parameters, expected to contain the documents service name.
- $container : ContainerInterface|null = null
-
An optional PSR-11 container for service resolution.
Tags
Return values
static —The instance of the class using this trait, for method chaining.
outputDocuments()
Renders a list of documents to the console output.
protected
outputDocuments(array<string|int, mixed> $documents, InputInterface $input, OutputInterface $output[, array<string|int, mixed>|null $fields = null ]) : void
The output format is determined by the verbosity level:
- Default: Displays the total count of documents found.
- Verbose (
-v): Renders a table with the fields defined in the$this->fieldsproperty. - Very Verbose (
-vv): Outputs the full documents as a prettyprint JSON array.
Parameters
- $documents : array<string|int, mixed>
-
The array of document objects to display.
- $input : InputInterface
-
The console input instance.
- $output : OutputInterface
-
The console output instance.
- $fields : array<string|int, mixed>|null = null
-
The optional fields to display (by default, use the $this->fields property).
upsert()
Upsert a document in the collection.
protected
upsert(InputInterface $input, OutputInterface $output, string|JsonSerializable|null|JsonSerializable|null} $option) : int
Parameters
- $input : InputInterface
- $output : OutputInterface
- $option : string|JsonSerializable|null|JsonSerializable|null}