Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / output-formatters / src / Formatters / RenderTableDataTrait.php
1 <?php
2 namespace Consolidation\OutputFormatters\Formatters;
3
4 use Consolidation\OutputFormatters\Options\FormatterOptions;
5 use Consolidation\OutputFormatters\StructuredData\RenderCellInterface;
6
7 trait RenderTableDataTrait
8 {
9     /**
10      * @inheritdoc
11      */
12     public function renderData($originalData, $restructuredData, FormatterOptions $options)
13     {
14         if ($originalData instanceof RenderCellInterface) {
15             return $this->renderEachCell($originalData, $restructuredData, $options);
16         }
17         return $restructuredData;
18     }
19
20     protected function renderEachCell($originalData, $restructuredData, FormatterOptions $options)
21     {
22         foreach ($restructuredData as $id => $row) {
23             foreach ($row as $key => $cellData) {
24                 $restructuredData[$id][$key] = $originalData->renderCell($key, $cellData, $options, $row);
25             }
26         }
27         return $restructuredData;
28     }
29 }