X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fconsolidation%2Foutput-formatters%2Fsrc%2FStructuredData%2FAbstractListData.php;fp=vendor%2Fconsolidation%2Foutput-formatters%2Fsrc%2FStructuredData%2FAbstractListData.php;h=7c635dbba7eef804febebd196106cde28e4dd93e;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/vendor/consolidation/output-formatters/src/StructuredData/AbstractListData.php b/vendor/consolidation/output-formatters/src/StructuredData/AbstractListData.php new file mode 100644 index 000000000..7c635dbba --- /dev/null +++ b/vendor/consolidation/output-formatters/src/StructuredData/AbstractListData.php @@ -0,0 +1,61 @@ +getArrayCopy()); + } + + protected function getReorderedFieldLabels($data, $options, $defaults) + { + $reorderer = new ReorderFields(); + $fieldLabels = $reorderer->reorder( + $this->getFields($options, $defaults), + $options->get(FormatterOptions::FIELD_LABELS, $defaults), + $data + ); + return $fieldLabels; + } + + protected function getFields($options, $defaults) + { + $fieldShortcut = $options->get(FormatterOptions::FIELD); + if (!empty($fieldShortcut)) { + return [$fieldShortcut]; + } + $result = $options->get(FormatterOptions::FIELDS, $defaults); + if (!empty($result)) { + return $result; + } + return $options->get(FormatterOptions::DEFAULT_FIELDS, $defaults); + } + + /** + * A structured list may provide its own set of default options. These + * will be used in place of the command's default options (from the + * annotations) in instances where the user does not provide the options + * explicitly (on the commandline) or implicitly (via a configuration file). + * + * @return array + */ + protected function defaultOptions() + { + return [ + FormatterOptions::FIELDS => [], + FormatterOptions::FIELD_LABELS => [], + ]; + } +}