Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
16 / 16 |
| ViewMode | |
100.00% |
1 / 1 |
|
100.00% |
5 / 5 |
11 | |
100.00% |
16 / 16 |
| initializeIterator | |
100.00% |
1 / 1 |
6 | |
100.00% |
10 / 10 |
|||
| query | |
100.00% |
1 / 1 |
1 | |
100.00% |
4 / 4 |
|||
| fields | |
100.00% |
1 / 1 |
1 | |
100.00% |
0 / 0 |
|||
| getIds | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| calculateDependencies | |
100.00% |
1 / 1 |
2 | |
100.00% |
0 / 0 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\node\Plugin\migrate\source\d6\ViewMode. | |
| */ | |
| namespace Drupal\node\Plugin\migrate\source\d6; | |
| /** | |
| * The view mode source. | |
| * | |
| * @MigrateSource( | |
| * id = "d6_view_mode", | |
| * source_provider = "content" | |
| * ) | |
| */ | |
| class ViewMode extends ViewModeBase { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| 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); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function query() { | |
| $query = $this->select('content_node_field_instance', 'cnfi') | |
| ->fields('cnfi', array( | |
| 'display_settings', | |
| )); | |
| return $query; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function fields() { | |
| return array( | |
| 'display_settings' => $this->t('Serialize data with display settings.'), | |
| ); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getIds() { | |
| $ids['view_mode']['type'] = 'string'; | |
| return $ids; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| 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; | |
| } | |
| } |