Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / src / Plugin / migrate / process / BlockSettings.php
1 <?php
2
3 namespace Drupal\block\Plugin\migrate\process;
4
5 use Drupal\Core\Block\BlockPluginInterface;
6 use Drupal\migrate\MigrateExecutableInterface;
7 use Drupal\migrate\ProcessPluginBase;
8 use Drupal\migrate\Row;
9
10 /**
11  * @MigrateProcessPlugin(
12  *   id = "block_settings"
13  * )
14  */
15 class BlockSettings extends ProcessPluginBase {
16
17   /**
18    * {@inheritdoc}
19    *
20    * Set the block configuration.
21    */
22   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
23     list($plugin, $delta, $old_settings, $title) = $value;
24     $settings = [];
25     $settings['label'] = $title;
26     if ($title) {
27       $settings['label_display'] = BlockPluginInterface::BLOCK_LABEL_VISIBLE;
28     }
29     else {
30       $settings['label_display'] = '0';
31     }
32     switch ($plugin) {
33       case 'aggregator_feed_block':
34         list(, $id) = explode('-', $delta);
35         $settings['block_count'] = $old_settings['aggregator']['item_count'];
36         $settings['feed'] = $id;
37         break;
38       case 'book_navigation':
39         $settings['block_mode'] = $old_settings['book']['block_mode'];
40         break;
41       case 'forum_active_block':
42       case 'forum_new_block':
43         $settings['block_count'] = $old_settings['forum']['block_num'];
44         break;
45       case 'statistics_popular_block':
46         $settings['top_day_num'] = $old_settings['statistics']['statistics_block_top_day_num'];
47         $settings['top_all_num'] = $old_settings['statistics']['statistics_block_top_all_num'];
48         $settings['top_last_num'] = $old_settings['statistics']['statistics_block_top_last_num'];
49         break;
50       case 'views_block:who_s_new-block_1':
51         $settings['items_per_page'] = $old_settings['user']['block_whois_new_count'];
52         break;
53       case 'views_block:who_s_online-who_s_online_block':
54         $settings['items_per_page'] = $old_settings['user']['max_list_count'];
55         break;
56     }
57     return $settings;
58   }
59
60 }