3 namespace Drupal\field\Plugin\migrate\source\d7;
5 use Drupal\migrate\Row;
6 use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
9 * Drupal 7 field source from database.
13 * This class is marked as internal and should not be extended. Use
14 * Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase instead.
18 * source_module = "field_sql_storage"
21 class Field extends DrupalSqlBase {
26 public function query() {
27 $query = $this->select('field_config', 'fc')
30 ->fields('fci', ['entity_type'])
31 ->condition('fc.active', 1)
32 ->condition('fc.storage_active', 1)
33 ->condition('fc.deleted', 0)
34 ->condition('fci.deleted', 0);
35 $query->join('field_config_instance', 'fci', 'fc.id = fci.field_id');
37 // If the Drupal 7 Title module is enabled, we don't want to migrate the
38 // fields it provides. The values of those fields will be migrated to the
39 // base fields they were replacing.
40 if ($this->moduleExists('title')) {
47 $query->condition('fc.field_name', $title_fields, 'NOT IN');
56 public function fields() {
58 'id' => $this->t('The field ID.'),
59 'field_name' => $this->t('The field name.'),
60 'type' => $this->t('The field type.'),
61 'module' => $this->t('The module that implements the field type.'),
62 'active' => $this->t('The field status.'),
63 'storage_type' => $this->t('The field storage type.'),
64 'storage_module' => $this->t('The module that implements the field storage type.'),
65 'storage_active' => $this->t('The field storage status.'),
66 'locked' => $this->t('Locked'),
67 'data' => $this->t('The field data.'),
68 'cardinality' => $this->t('Cardinality'),
69 'translatable' => $this->t('Translatable'),
70 'deleted' => $this->t('Deleted'),
71 'instances' => $this->t('The field instances.'),
78 public function prepareRow(Row $row, $keep = TRUE) {
79 foreach (unserialize($row->getSourceProperty('data')) as $key => $value) {
80 $row->setSourceProperty($key, $value);
83 $instances = $this->select('field_config_instance', 'fci')
85 ->condition('field_name', $row->getSourceProperty('field_name'))
86 ->condition('entity_type', $row->getSourceProperty('entity_type'))
89 $row->setSourceProperty('instances', $instances);
91 return parent::prepareRow($row);
97 public function getIds() {