ViewMode.php in Zircon Profile 8
File
core/modules/node/src/Plugin/migrate/source/d6/ViewMode.php
View source
<?php
namespace Drupal\node\Plugin\migrate\source\d6;
class ViewMode extends ViewModeBase {
protected function initializeIterator() {
$rows = array();
$result = $this
->prepareQuery()
->execute();
while ($field_row = $result
->fetchAssoc()) {
$field_row['display_settings'] = unserialize($field_row['display_settings']);
foreach ($this
->getViewModes() as $view_mode) {
if (isset($field_row['display_settings'][$view_mode]) && empty($field_row['display_settings'][$view_mode]['exclude'])) {
if (!isset($rows[$view_mode])) {
$rows[$view_mode]['entity_type'] = 'node';
$rows[$view_mode]['view_mode'] = $view_mode;
}
}
}
}
return new \ArrayIterator($rows);
}
public function query() {
$query = $this
->select('content_node_field_instance', 'cnfi')
->fields('cnfi', array(
'display_settings',
));
return $query;
}
public function fields() {
return array(
'display_settings' => $this
->t('Serialize data with display settings.'),
);
}
public function getIds() {
$ids['view_mode']['type'] = 'string';
return $ids;
}
public function calculateDependencies() {
$this->dependencies = parent::calculateDependencies();
if (isset($this->configuration['constants']['targetEntityType'])) {
$this
->addDependency('module', $this->entityManager
->getDefinition($this->configuration['constants']['targetEntityType'])
->getProvider());
}
return $this->dependencies;
}
}