Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / output-formatters / src / Transformations / UnstructuredDataFieldAccessor.php
1 <?php
2 namespace Consolidation\OutputFormatters\Transformations;
3
4 use Dflydev\DotAccessData\Data;
5
6 class UnstructuredDataFieldAccessor
7 {
8     protected $data;
9
10     public function __construct($data)
11     {
12         $this->data = $data;
13     }
14
15     public function get($fields)
16     {
17         $data = new Data($this->data);
18         $result = new Data();
19         foreach ($fields as $key => $label) {
20             $item = $data->get($key);
21             if (isset($item)) {
22                 if ($label == '.') {
23                     if (!is_array($item)) {
24                         return $item;
25                     }
26                     foreach ($item as $key => $value) {
27                         $result->set($key, $value);
28                     }
29                 } else {
30                     $result->set($label, $data->get($key));
31                 }
32             }
33         }
34         return $result->export();
35     }
36 }