Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / field / src / Plugin / migrate / source / d7 / FieldInstancePerViewMode.php
index 7339e764a889334b7a36d0ceb3560b581f115cb3..7d5ee81a59fb1787d055fcb8565b48e4c0448e55 100644 (file)
@@ -2,69 +2,43 @@
 
 namespace Drupal\field\Plugin\migrate\source\d7;
 
-use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
-
 /**
  * The field instance per view mode source class.
  *
  * @MigrateSource(
  *   id = "d7_field_instance_per_view_mode",
- *   source_provider = "field"
+ *   source_module = "field"
  * )
  */
-class FieldInstancePerViewMode extends DrupalSqlBase {
+class FieldInstancePerViewMode extends FieldInstance {
 
   /**
    * {@inheritdoc}
    */
   protected function initializeIterator() {
-    $rows = [];
-    $result = $this->prepareQuery()->execute();
-    foreach ($result as $field_instance) {
-      $data = unserialize($field_instance['data']);
-      // We don't need to include the serialized data in the returned rows.
-      unset($field_instance['data']);
+    $instances = parent::initializeIterator();
 
-      foreach ($data['display'] as $view_mode => $info) {
-        // Rename type to formatter_type in the info array.
-        $info['formatter_type'] = $info['type'];
-        unset($info['type']);
-
-        $rows[] = array_merge($field_instance, $info, [
+    $rows = [];
+    foreach ($instances->getArrayCopy() as $instance) {
+      $data = unserialize($instance['data']);
+      foreach ($data['display'] as $view_mode => $formatter) {
+        $rows[] = array_merge($instance, [
           'view_mode' => $view_mode,
+          'formatter' => $formatter,
         ]);
       }
     }
     return new \ArrayIterator($rows);
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function query() {
-    $query = $this->select('field_config_instance', 'fci')
-      ->fields('fci', ['entity_type', 'bundle', 'field_name', 'data'])
-      ->fields('fc', ['type']);
-    $query->join('field_config', 'fc', 'fc.field_name = fci.field_name');
-    return $query;
-  }
-
   /**
    * {@inheritdoc}
    */
   public function fields() {
-    return [
-      'entity_type' => $this->t('The entity type ID.'),
-      'bundle' => $this->t('The bundle ID.'),
-      'field_name' => $this->t('Machine name of the field.'),
+    return array_merge(parent::fields(), [
       'view_mode' => $this->t('The original machine name of the view mode.'),
-      'label' => $this->t('The display label of the field.'),
-      'type' => $this->t('The field ID.'),
-      'formatter_type' => $this->t('The formatter ID.'),
-      'settings' => $this->t('Array of formatter-specific settings.'),
-      'module' => $this->t('The module providing the formatter.'),
-      'weight' => $this->t('Display weight of the field.'),
-    ];
+      'formatter' => $this->t('The formatter settings.'),
+    ]);
   }
 
   /**
@@ -87,11 +61,4 @@ class FieldInstancePerViewMode extends DrupalSqlBase {
     ];
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function count() {
-    return $this->initializeIterator()->count();
-  }
-
 }