View source
<?php
namespace Drupal\field\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class Field extends DrupalSqlBase {
public function query() {
$query = $this
->select('field_config', 'fc')
->distinct()
->fields('fc')
->fields('fci', array(
'entity_type',
))
->condition('fc.active', 1)
->condition('fc.deleted', 0)
->condition('fc.storage_active', 1);
$query
->join('field_config_instance', 'fci', 'fc.id = fci.field_id');
return $query;
}
public function fields() {
return array(
'field_name' => $this
->t('The name of this field.'),
'type' => $this
->t('The type of this field.'),
'module' => $this
->t('The module that implements the field type.'),
'storage' => $this
->t('The field storage.'),
'locked' => $this
->t('Locked'),
'cardinality' => $this
->t('Cardinality'),
'translatable' => $this
->t('Translatable'),
);
}
public function prepareRow(Row $row, $keep = TRUE) {
foreach (unserialize($row
->getSourceProperty('data')) as $key => $value) {
$row
->setSourceProperty($key, $value);
}
return parent::prepareRow($row);
}
public function getIds() {
return array(
'field_name' => array(
'type' => 'string',
'alias' => 'fc',
),
'entity_type' => array(
'type' => 'string',
'alias' => 'fci',
),
);
}
}