Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / field / src / Plugin / migrate / source / d7 / FieldInstancePerViewMode.php
1 <?php
2
3 namespace Drupal\field\Plugin\migrate\source\d7;
4
5 /**
6  * The field instance per view mode source class.
7  *
8  * @MigrateSource(
9  *   id = "d7_field_instance_per_view_mode",
10  *   source_module = "field"
11  * )
12  */
13 class FieldInstancePerViewMode extends FieldInstance {
14
15   /**
16    * {@inheritdoc}
17    */
18   protected function initializeIterator() {
19     $instances = parent::initializeIterator();
20
21     $rows = [];
22     foreach ($instances->getArrayCopy() as $instance) {
23       $data = unserialize($instance['data']);
24       foreach ($data['display'] as $view_mode => $formatter) {
25         $rows[] = array_merge($instance, [
26           'view_mode' => $view_mode,
27           'formatter' => $formatter,
28         ]);
29       }
30     }
31     return new \ArrayIterator($rows);
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   public function fields() {
38     return array_merge(parent::fields(), [
39       'view_mode' => $this->t('The original machine name of the view mode.'),
40       'formatter' => $this->t('The formatter settings.'),
41     ]);
42   }
43
44   /**
45    * {@inheritdoc}
46    */
47   public function getIds() {
48     return [
49       'entity_type' => [
50         'type' => 'string',
51       ],
52       'bundle' => [
53         'type' => 'string',
54       ],
55       'view_mode' => [
56         'type' => 'string',
57       ],
58       'field_name' => [
59         'type' => 'string',
60       ],
61     ];
62   }
63
64 }