FormatterManager
class FormatterManager (View source)
Manage a collection of formatters; return one on request.
Properties
protected | $formatters | var FormatterInterface[] |
|
protected | $arraySimplifiers | var SimplifyToArrayInterface[] |
Methods
No description
No description
No description
Return a set of InputOption based on the annotations of a command.
Given a list of available fields, return a list of field descriptions.
Return the identifiers for all valid data types that have been registered.
Format and write output
No description
Fetch the requested formatter.
Test to see if the stipulated format exists
Render the data as necessary (e.g. to select or reorder fields).
Determine if the provided data is compatible with the formatter being used.
Convert from one format to another if necessary prior to restructuring.
Restructure the data as necessary (e.g. to select or reorder fields).
Allow the formatter access to the raw structured data prior to restructuring. For example, the 'list' formatter may wish to display the row keys when provided table output. If this function returns a result that does not evaluate to 'false', then that result will be used as-is, and restructuring and validation will not occur.
Allow the formatter to mess with the configuration options before any transformations et. al. get underway.
Details
__construct()
No description
addDefaultFormatters()
No description
addDefaultSimplifiers()
No description
FormatterManager
addFormatter(string $key, FormatterInterface $formatter)
Add a formatter
FormatterManager
addSimplifier(SimplifyToArrayInterface $simplifier)
Add a simplifier
InputOption[]
automaticOptions(FormatterOptions $options, $dataType)
Return a set of InputOption based on the annotations of a command.
protected string[]
availableFieldsList($availableFields)
Given a list of available fields, return a list of field descriptions.
array
validFormats(mixed $dataType)
Return the identifiers for all valid data types that have been registered.
isValidFormat(FormatterInterface $formatter, $dataType)
No description
isValidDataType(FormatterInterface $formatter, ReflectionClass $dataType)
No description
write(OutputInterface $output, string $format, mixed $structuredOutput, FormatterOptions $options)
Format and write output
protected
validateAndRestructure(FormatterInterface $formatter, $structuredOutput, FormatterOptions $options)
No description
FormatterInterface
getFormatter(string $format)
Fetch the requested formatter.
hasFormatter($format)
Test to see if the stipulated format exists
mixed
renderData(FormatterInterface $formatter, mixed $originalData, mixed $restructuredData, FormatterOptions $options)
Render the data as necessary (e.g. to select or reorder fields).
mixed
validateData(FormatterInterface $formatter, mixed $structuredOutput, FormatterOptions $options)
Determine if the provided data is compatible with the formatter being used.
protected
simplifyToArray($structuredOutput, FormatterOptions $options)
No description
protected
canSimplifyToArray(ReflectionClass $structuredOutput)
No description
convertData($structuredOutput, FormatterOptions $options)
Convert from one format to another if necessary prior to restructuring.
mixed
restructureData(mixed $structuredOutput, FormatterOptions $options)
Restructure the data as necessary (e.g. to select or reorder fields).
mixed
overrideRestructure(FormatterInterface $formatter, mixed $structuredOutput, FormatterOptions $options)
Allow the formatter access to the raw structured data prior to restructuring. For example, the 'list' formatter may wish to display the row keys when provided table output. If this function returns a result that does not evaluate to 'false', then that result will be used as-is, and restructuring and validation will not occur.
FormatterOptions
overrideOptions(FormatterInterface $formatter, mixed $structuredOutput, FormatterOptions $options)
Allow the formatter to mess with the configuration options before any transformations et. al. get underway.