Manage a collection of formatters; return one on request.
Visibility | Function |
---|---|
public | __construct() : void |
public | addDefaultFormatters() : void |
public | addDefaultSimplifiers() : void |
public | addFormatter(string $key, string/\Consolidation\OutputFormatters\Formatters\FormatterInterface $formatter) | : \Consolidation\OutputFormatters\FormatterManager
public | addSimplifier(\Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface $simplifier) | : \Consolidation\OutputFormatters\FormatterManager
Contains some helper functions used by exceptions in this project.
Visibility | Function |
---|---|
protected static | describeAllowedTypes(mixed $allowedTypes) | : void
protected static | describeDataType(\ReflectionClass $data) | : string
This class extends \Exception
Represents an incompatibility between the output data and selected formatter.
Visibility | Function |
---|---|
public | __construct(\Consolidation\OutputFormatters\Formatters\FormatterInterface $formatter, mixed $data, mixed $allowedTypes) | : void
This class extends \Consolidation\OutputFormatters\Exception\AbstractDataFormatException
Represents an incompatibility between the output data and selected formatter.
Visibility | Function |
---|---|
public | __construct(mixed $format, mixed $data, mixed $validFormats) | : void
This class extends \Consolidation\OutputFormatters\Exception\AbstractDataFormatException
Indicates that the requested format does not exist.
Visibility | Function |
---|---|
public | __construct(mixed $field) | : void
This class extends \Exception
Indicates that the requested format does not exist.
Visibility | Function |
---|---|
public | __construct(mixed $format) | : void
This class extends \Exception
Comma-separated value formatters Display the provided structured data in a comma-separated list. If there are multiple records provided, then they will be printed one per line. The primary data types accepted are RowsOfFields and PropertyList. The later behaves exactly like the former, save for the fact that it contains but a single row. This formmatter can also accept a PHP array; this is also interpreted as a single-row of data with no header.
Visibility | Function |
---|---|
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
','
)This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface, \Consolidation\OutputFormatters\Formatters\RenderDataInterface
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
Json formatter Convert an array or ArrayObject into Json.
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface
Display the data in a simple list. This formatter prints a plain, unadorned list of data, with each data item appearing on a separate line. If you wish your list to contain headers, then use the table formatter, and wrap your data in an PropertyList.
Visibility | Function |
---|---|
public | overrideRestructure(mixed $structuredOutput, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Transformations\OverrideRestructureInterface, \Consolidation\OutputFormatters\Formatters\RenderDataInterface
Print_r formatter Run provided date thruogh print_r.
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface
Visibility | Function |
---|---|
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
Display sections of data. This formatter takes data in the RowsOfFields data type. Each row represents one section; the data in each section is rendered in two columns, with the key in the first column and the value in the second column.
Visibility | Function |
---|---|
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface, \Consolidation\OutputFormatters\Formatters\RenderDataInterface
Serialize formatter Run provided date thruogh serialize.
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface
String formatter This formatter is used as the default action when no particular formatter is requested. It will print the provided data only if it is a string; if any other type is given, then nothing is printed.
Visibility | Function |
---|---|
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | overrideOptions(mixed $structuredOutput, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : \Consolidation\OutputFormatters\Options\FormatterOptions
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface, \Consolidation\OutputFormatters\Options\OverrideOptionsInterface
Display a table of data with the Symfony Table class. This formatter takes data of either the RowsOfFields or PropertyList data type. Tables can be rendered with the rows running either vertically (the normal orientation) or horizontally. By default, associative lists will be displayed as two columns, with the key in the first column and the value in the second column.
Visibility | Function |
---|---|
public | __construct() : void |
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface, \Consolidation\OutputFormatters\Formatters\RenderDataInterface
Tab-separated value formatters Display the provided structured data in a tab-separated list. Output escaping is much lighter, since there is no allowance for altering the delimiter.
Visibility | Function |
---|---|
public | renderData(mixed $originalData, mixed $restructuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class extends \Consolidation\OutputFormatters\Formatters\CsvFormatter
This class implements \Consolidation\OutputFormatters\Formatters\RenderDataInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface, \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface, \Consolidation\OutputFormatters\Formatters\FormatterInterface
Var_export formatter Run provided date thruogh var_export.
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface
Display a table of data with the Symfony Table class. This formatter takes data of either the RowsOfFields or PropertyList data type. Tables can be rendered with the rows running either vertically (the normal orientation) or horizontally. By default, associative lists will be displayed as two columns, with the key in the first column and the value in the second column.
Visibility | Function |
---|---|
public | __construct() : void |
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | validDataTypes() : void |
public | validate(mixed $structuredData) | : mixed
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface, \Consolidation\OutputFormatters\Validate\ValidDataTypesInterface, \Consolidation\OutputFormatters\Validate\ValidationInterface
Yaml formatter Convert an array or ArrayObject into Yaml.
Visibility | Function |
---|---|
public | write(\Symfony\Component\Console\Output\OutputInterface $output, mixed $data, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : string
This class implements \Consolidation\OutputFormatters\Formatters\FormatterInterface
FormetterOptions holds information that affects the way a formatter renders its output. There are three places where a formatter might get options from: 1. 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. 2. Options specified by the user, e.g. by commandline options. 3. 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.
Visibility | Function |
---|---|
public | __construct(array $configurationData=array(), array $options=array()) | : void
public | get(string $key, array $defaults=array(), bool/mixed $default=false) | : mixed
Visibility | Function |
---|---|
public | overrideOptions(mixed $structuredOutput, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : \Consolidation\OutputFormatters\Options\FormatterOptions
Holds an array where each element of the array is one row, and each row contains an associative array where the keys are the field names, and the values are the field data. It is presumed that every row contains the same keys.
Visibility | Function |
---|---|
public | __construct(mixed $data) | : void
public | addRenderer(\Consolidation\OutputFormatters\StructuredData\RenderCellInterface $renderer, string $priority='normal' ) | : \Consolidation\OutputFormatters\StructuredData\$this
'normal'
)This class extends \ArrayObject
This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, \Consolidation\OutputFormatters\StructuredData\RestructureInterface, \Consolidation\OutputFormatters\StructuredData\ListDataInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
Old name for PropertyList class.
Visibility | Function |
---|
This class extends \Consolidation\OutputFormatters\StructuredData\PropertyList
This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, \Consolidation\OutputFormatters\StructuredData\RestructureInterface, \Consolidation\OutputFormatters\StructuredData\ListDataInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
Visibility | Function |
---|---|
public | __construct(\callable $renderFunction) | : void
public | renderCell(mixed $key, mixed $cellData, \Consolidation\OutputFormatters\Options\FormatterOptions $options, mixed $rowData) | : void
This class implements \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
Visibility | Function |
---|---|
public | getDomData() : \DomDocument Convert data into a \DomDocument. |
This class implements \Consolidation\OutputFormatters\StructuredData\Xml\DomDataInterface
Visibility | Function |
---|---|
public | getListData(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : array
Visibility | Function |
---|---|
public | getOriginalData() : mixed Return the original data for this table. Used by any formatter that expects an array. |
Holds an array where each element of the array is one key : value pair. The keys must be unique, as is typically the case for associative arrays.
Visibility | Function |
---|---|
public | getListData(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
public | restructure(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : \Consolidation\OutputFormatters\StructuredData\Consolidation\OutputFormatters\Transformations\TableTransformation
This class extends \Consolidation\OutputFormatters\StructuredData\AbstractStructuredList
This class implements \Consolidation\OutputFormatters\StructuredData\RenderCellInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface, \Consolidation\OutputFormatters\StructuredData\ListDataInterface, \Consolidation\OutputFormatters\StructuredData\RestructureInterface, \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable
Visibility | Function |
---|---|
public | addRenderer(\Consolidation\OutputFormatters\StructuredData\RenderCellInterface $renderer) | : \Consolidation\OutputFormatters\StructuredData\$this
This class implements \Consolidation\OutputFormatters\StructuredData\RenderCellInterface
Visibility | Function |
---|---|
public | renderCell(string $key, mixed $cellData, \Consolidation\OutputFormatters\Options\FormatterOptions $options, array $rowData) | : mixed
Visibility | Function |
---|---|
public | restructure(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : void
Holds an array where each element of the array is one row, and each row contains an associative array where the keys are the field names, and the values are the field data. It is presumed that every row contains the same keys.
Visibility | Function |
---|---|
public | getListData(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
public | restructure(\Consolidation\OutputFormatters\Options\FormatterOptions $options) | : \Consolidation\OutputFormatters\StructuredData\Consolidation\OutputFormatters\Transformations\TableTransformation
This class extends \Consolidation\OutputFormatters\StructuredData\AbstractStructuredList
This class implements \Consolidation\OutputFormatters\StructuredData\RenderCellInterface, \Consolidation\OutputFormatters\StructuredData\RenderCellCollectionInterface, \Consolidation\OutputFormatters\StructuredData\ListDataInterface, \Consolidation\OutputFormatters\StructuredData\RestructureInterface, \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable
Visibility | Function |
---|---|
public | getOriginalData() : mixed Return the original data for this table. Used by any formatter that is -not- a table. |
public | getTableData(bool/boolean $includeRowKey=false) | : array
Visibility | Function |
---|---|
public | getDomData() : \DomDocument Convert data into a \DomDocument. |
Visibility | Function |
---|---|
public | __construct(array $elementList=array()) | : void
public | arrayToXML(mixed $structuredData) | : void
This class implements \Consolidation\OutputFormatters\StructuredData\Xml\XmlSchemaInterface
When using arrays, we could represent XML data in a number of different ways. For example, given the following XML data strucutre: blah a b c This could be: [ 'id' => 1, 'name' => 'doc', 'foobars' => [ [ 'id' => '123', 'name' => 'blah', 'widgets' => [ [ 'foo' => 'a', 'bar' => 'b', 'baz' => 'c', ] ], ], ] ] The challenge is more in going from an array back to the more structured xml format. Note that any given key => string mapping could represent either an attribute, or a simple XML element containing only a string value. In general, we do not want to add extra layers of nesting in the data structure to disambiguate between these kinds of data, as we want the source data to render cleanly into other formats, e.g. yaml, json, et. al., and we do not want to force every data provider to have to consider the optimal xml schema for their data. Our strategy, therefore, is to expect clients that wish to provide a very specific xml representation to return a DOMDocument, and, for other data structures where xml is a secondary concern, then we will use some default heuristics to convert from arrays to xml.
Visibility | Function |
---|---|
public | arrayToXml(mixed $structuredData) | : \DOMDocument
Simplify a DOMDocument to an array.
Visibility | Function |
---|---|
public | __construct() : void |
public | canSimplify(\ReflectionClass $dataType) | : bool
public | simplifyToArray(mixed $structuredData, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : void
This class implements \Consolidation\OutputFormatters\Transformations\SimplifyToArrayInterface
Visibility | Function |
---|---|
public | overrideRestructure(mixed $structuredOutput, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : mixed
Visibility | Function |
---|---|
public | getOriginalData() : mixed |
This class extends \Consolidation\OutputFormatters\Transformations\TableTransformation
This class implements \Consolidation\OutputFormatters\StructuredData\OriginalDataInterface, \Consolidation\OutputFormatters\StructuredData\TableDataInterface, \IteratorAggregate, \Traversable, \ArrayAccess, \Serializable, \Countable
Transform a string of properties into a PHP associative array. Input: one: red two: white three: blue Output: [ 'one' => 'red', 'two' => 'white', 'three' => 'blue', ]
Visibility | Function |
---|---|
public static | parse(mixed $data) | : void
Reorder the field labels based on the user-selected fields to display.
Visibility | Function |
---|---|
public | reorder(string/array $fields, array $fieldLabels, array $data) | : array
protected | convertToRegex(mixed $str) | : void
Visibility | Function |
---|---|
public | canSimplify(\ReflectionClass $structuredOutput) | : bool
public | simplifyToArray(mixed $structuredOutput, \Consolidation\OutputFormatters\Options\FormatterOptions $options) | : array
Visibility | Function |
---|---|
public | __construct(mixed $data, mixed $fieldLabels, array $rowLabels=array()) | : void
public | getHeader(mixed $key) | : mixed
This class extends \ArrayObject
This class implements \Countable, \Serializable, \ArrayAccess, \Traversable, \IteratorAggregate, \Consolidation\OutputFormatters\StructuredData\TableDataInterface, \Consolidation\OutputFormatters\StructuredData\OriginalDataInterface
Visibility | Function |
---|---|
public | __construct(mixed $width) | : void
public | minimumWidth(mixed $colkey, mixed $width) | : void
Calculate column widths for table cells. Influenced by Drush and webmozart/console.
Visibility | Function |
---|---|
public | __construct() : void |
public | calculate(mixed $availableWidth, \Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths $dataWidths, \Consolidation\OutputFormatters\Transformations\Wrap\ColumnWidths $minimumWidths) | : void
public | calculateLongestCell(mixed $rows) | : void
Calculate the width of data in table cells in preparation for word wrapping.
Visibility | Function |
---|---|
public | __construct(array $widths=array()) | : void
public | adjustMinimumWidths(mixed $availableWidth, mixed $dataCellWidths) | : void
Formatters may implement ValidationInterface in order to indicate whether a particular data structure is supported. Any formatter that does not implement ValidationInterface is assumed to only operate on arrays, or data types that implement SimplifyToArrayInterface.
Visibility | Function |
---|---|
public | isValidDataType(\ReflectionClass $dataType) | : bool
public | validate(mixed $structuredData) | : mixed
Formatters may implement ValidDataTypesInterface in order to indicate exactly which formats they support. The validDataTypes method can be called to retrieve a list of data types useful in providing hints in exception messages about which data types can be used with the formatter. Note that it is OPTIONAL for formatters to implement this interface. If a formatter implements only ValidationInterface, then clients that request the formatter via FormatterManager::write() will still get a list (via an InvalidFormatException) of all of the formats that are usable with the provided data type. Implementing ValidDataTypesInterface is benefitial to clients who instantiate a formatter directly (via
new
). Formatters that implement ValidDataTypesInterface may wish to use ValidDataTypesTrait.
Visibility | Function |
---|---|
public | validDataTypes() : \ReflectionClass[] Return the list of data types acceptable to this formatter |
This class implements \Consolidation\OutputFormatters\Validate\ValidationInterface