ViewMode.php in Zircon Profile 8
File
core/modules/field/src/Plugin/migrate/source/d7/ViewMode.php
View source
<?php
namespace Drupal\field\Plugin\migrate\source\d7;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
class ViewMode extends DrupalSqlBase {
protected function initializeIterator() {
$rows = [];
$result = $this
->prepareQuery()
->execute();
foreach ($result as $field_instance) {
$data = unserialize($field_instance['data']);
foreach (array_keys($data['display']) as $view_mode) {
$key = $field_instance['entity_type'] . '.' . $view_mode;
$rows[$key] = [
'entity_type' => $field_instance['entity_type'],
'view_mode' => $view_mode,
];
}
}
return new \ArrayIterator($rows);
}
public function fields() {
return [
'view_mode' => $this
->t('The view mode ID.'),
'entity_type' => $this
->t('The entity type ID.'),
];
}
public function query() {
return $this
->select('field_config_instance', 'fci')
->fields('fci', [
'entity_type',
'data',
]);
}
public function getIds() {
return [
'entity_type' => [
'type' => 'string',
],
'view_mode' => [
'type' => 'string',
],
];
}
public function count() {
return $this
->initializeIterator()
->count();
}
}
Classes
Name |
Description |
ViewMode |
Plugin annotation
@MigrateSource(
id = "d7_view_mode"
) |