FormatterOptions
class FormatterOptions (View source)
FormatterOptions holds information that affects the way a formatter renders its output.
There are three places where a formatter might get options from:
-
Configuration associated with the command that produced the output. This is passed in to FormatterManager::write() along with the data to format. It might originally come from annotations on the command, or it might come from another source. Examples include the field labels for a table, or the default list of fields to display.
-
Options specified by the user, e.g. by commandline options.
-
Default values associated with the formatter itself.
This class caches configuration from sources (1) and (2), and expects to be provided the defaults, (3), whenever a value is requested.
Constants
FORMAT |
|
DEFAULT_FORMAT |
|
TABLE_STYLE |
|
TABLE_EMPTY_MESSAGE |
|
LIST_ORIENTATION |
|
FIELDS |
|
FIELD |
|
INCLUDE_FIELD_LABELS |
|
ROW_LABELS |
|
FIELD_LABELS |
|
DEFAULT_FIELDS |
|
DEFAULT_TABLE_FIELDS |
|
DEFAULT_STRING_FIELD |
|
DELIMITER |
|
CSV_ENCLOSURE |
|
CSV_ESCAPE_CHAR |
|
LIST_DELIMITER |
|
TERMINAL_WIDTH |
|
METADATA_TEMPLATE |
|
HUMAN_READABLE |
|
Properties
protected | $configurationData | var array |
|
protected | $options | var array |
|
protected | $input | var InputInterface |
Methods
Create a new FormatterOptions with the configuration data and the user-specified options for this request.
Create a new FormatterOptions object with new configuration data (provided), and the same options data as this instance.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Get a formatter option
Get the fields based on the selections made by the user and the available annotation data. The fields are reported as the user selected them, and therefore may be either the field machine name, or its corresponding human-readable label.
Returns 'true' iff the fields selected by the user (or the default fields, if none explicitly selected) contain the specified field name.
No description
Return the XmlSchema to use with --format=xml for data types that support that. This is used when an array needs to be converted into xml.
Determine the format that was requested by the caller.
Look up a key, and return its raw value.
Reduce provided defaults to the single item identified by '$key', if it exists, or an empty array otherwise.
Look up all of the items associated with the provided defaults.
Given the raw value for a specific key, do any type conversion (e.g. from a textual list to an array) needed for the data.
Convert from a textual list to an array
Given a specific key, return the class method name of the parsing method for data stored under this key.
Change the configuration data for this formatter options object.
Change one configuration value for this formatter option.
Change one configuration value for this formatter option, but only if it does not already have a value set.
Return a reference to the configuration data for this object.
Set all of the options that were specified by the user for this request.
Change one option value specified by the user for this request.
Return a reference to the user-specified options for this request.
Provide a Symfony Console InputInterface containing the user-specified options for this request.
Return all of the options from the provided $defaults array that exist in our InputInterface object.
Details
__construct(array $configurationData = [], array $options = [])
Create a new FormatterOptions with the configuration data and the user-specified options for this request.
FormatterOptions
override(array $configurationData)
Create a new FormatterOptions object with new configuration data (provided), and the same options data as this instance.
setTableStyle($style)
No description
setDelimiter($delimiter)
No description
setCsvEnclosure($enclosure)
No description
setCsvEscapeChar($escapeChar)
No description
setListDelimiter($listDelimiter)
No description
setIncludeFieldLables($includFieldLables)
No description
setListOrientation($listOrientation)
No description
setRowLabels($rowLabels)
No description
setDefaultFields($fields)
No description
setFieldLabels($fieldLabels)
No description
setTableEmptyMessage($emptyMessage)
No description
setTableDefaultFields($defaultTableFields)
No description
setDefaultStringField($defaultStringField)
No description
setWidth($width)
No description
setHumanReadable($isHumanReadable = true)
No description
mixed
get(string $key, array $defaults = [], mixed $default = false)
Get a formatter option
mixed
fields(array $defaults = [], mixed $default = false)
Get the fields based on the selections made by the user and the available annotation data. The fields are reported as the user selected them, and therefore may be either the field machine name, or its corresponding human-readable label.
fieldsContain($fieldName)
Returns 'true' iff the fields selected by the user (or the default fields, if none explicitly selected) contain the specified field name.
Note that the provided field name may be either the machine name for the field, or the human-readable field label.
protected
fieldAlias($fieldName)
No description
XmlSchema
getXmlSchema()
Return the XmlSchema to use with --format=xml for data types that support that. This is used when an array needs to be converted into xml.
string
getFormat(array $defaults = [])
Determine the format that was requested by the caller.
protected mixed
fetch(string $key, array $defaults = [], mixed $default = false)
Look up a key, and return its raw value.
protected array
defaultsForKey(string $key, array $defaults, $default = false)
Reduce provided defaults to the single item identified by '$key', if it exists, or an empty array otherwise.
protected array
fetchRawValues(array $defaults = [])
Look up all of the items associated with the provided defaults.
protected mixed
parse(string $key, mixed $value)
Given the raw value for a specific key, do any type conversion (e.g. from a textual list to an array) needed for the data.
array
parsePropertyList(string $value)
Convert from a textual list to an array
protected string
getOptionFormat(string $key)
Given a specific key, return the class method name of the parsing method for data stored under this key.
FormatterOptions
setConfigurationData(array $configurationData)
Change the configuration data for this formatter options object.
protected FormatterOptions
setConfigurationValue(string $key, mixed $value)
Change one configuration value for this formatter option.
FormatterOptions
setConfigurationDefault(string $key, mixed $value)
Change one configuration value for this formatter option, but only if it does not already have a value set.
array
getConfigurationData()
Return a reference to the configuration data for this object.
FormatterOptions
setOptions(array $options)
Set all of the options that were specified by the user for this request.
FormatterOptions
setOption(string $key, mixed $value)
Change one option value specified by the user for this request.
array
getOptions()
Return a reference to the user-specified options for this request.
FormatterOptions
setInput(InputInterface $input)
Provide a Symfony Console InputInterface containing the user-specified options for this request.
array
getInputOptions(array $defaults)
Return all of the options from the provided $defaults array that exist in our InputInterface object.