Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / output-formatters / src / Transformations / TableTransformation.php
index 52e9403b170606a0c898cc87460d0f3633532582..0922974513254313b67d416eb4355bc8ead9758f 100644 (file)
@@ -4,8 +4,11 @@ namespace Consolidation\OutputFormatters\Transformations;
 use Consolidation\OutputFormatters\StructuredData\TableDataInterface;
 use Consolidation\OutputFormatters\StructuredData\OriginalDataInterface;
 use Consolidation\OutputFormatters\StructuredData\MetadataHolderInterface;
+use Consolidation\OutputFormatters\Options\FormatterOptions;
+use Consolidation\OutputFormatters\Formatters\TsvFormatter;
+use Symfony\Component\Console\Output\BufferedOutput;
 
-class TableTransformation extends \ArrayObject implements TableDataInterface, OriginalDataInterface
+class TableTransformation extends \ArrayObject implements TableDataInterface, StringTransformationInterface, OriginalDataInterface
 {
     protected $headers;
     protected $rowLabels;
@@ -40,6 +43,22 @@ class TableTransformation extends \ArrayObject implements TableDataInterface, Or
         return $this->layout == self::LIST_LAYOUT;
     }
 
+    /**
+     * @inheritdoc
+     */
+    public function simplifyToString(FormatterOptions $options)
+    {
+        $alternateFormatter = new TsvFormatter();
+        $output = new BufferedOutput();
+
+        try {
+            $data = $alternateFormatter->validate($this->getArrayCopy());
+            $alternateFormatter->write($output, $this->getArrayCopy(), $options);
+        } catch (\Exception $e) {
+        }
+        return $output->fetch();
+    }
+
     protected static function transformRows($data, $fieldLabels)
     {
         $rows = [];