Oihana PHP Arango

DocumentsCommandExist uses trait:short

Provides the implementation for an 'exist' command action.

This trait should be used in a Symfony Console command to check if one or more documents exist based on a given set of identifiers.

Example

bin/console command:places exist "65910397"

Command:places
==============

Check if the document(s) exist
------------------------------

The document 65910397 exist

✅  Done in 4 ms
----------------

Thank you and see you soon!

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.
exist()  : int
Checks if all provided documents exist in the collection.
fetchDocuments()  : array<string|int, mixed>
Fetch all documents from the OpenEdge database.
initializeDocuments()  : static
Initializes the 'documents' property.
outputDocuments()  : void
Renders a list of documents to the console output.

Properties

$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
throws
UnexpectedValueException

If the 'documents' property is not set.

exist()

Checks if all provided documents exist in the collection.

protected exist(InputInterface $input, OutputInterface $output[, mixed|null $option = null ]) : int

This method takes a single identifier or an array of identifiers and verifies their existence. The command's exit code does not reflect the outcome of the existence check; it only indicates that the operation itself completed successfully.

Parameters
$input : InputInterface

The console input instance.

$output : OutputInterface

The console output instance.

$option : mixed|null = null

A single identifier or an array of identifiers to check.

Tags
throws
DependencyException
NotFoundException
ContainerExceptionInterface
NotFoundExceptionInterface
ReflectionException
ArangoException
BindException
Return values
int

Always returns ExitCode::SUCCESS.

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
throws
BindException
ContainerExceptionInterface
ArangoException
NotFoundExceptionInterface
ReflectionException
Return values
array<string|int, mixed>

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
throws
ContainerExceptionInterface

If an error occurs while retrieving the entry from the container.

NotFoundExceptionInterface

If no entry was found in the container for the given service name.

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->fields property.
  • 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).

On this page

Search results