Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / fixtures / update / drupal-8.block-context-manager-2354889.php
1 <?php
2
3 /**
4  * @file
5  * Contains database additions to drupal-8.bare.standard.php.gz for testing the
6  * upgrade path of https://www.drupal.org/node/2354889.
7  */
8
9 use Drupal\Core\Database\Database;
10 use Drupal\Core\Serialization\Yaml;
11
12 $connection = Database::getConnection();
13
14 // A custom block with visibility settings.
15 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml'));
16
17 // A custom block without any visibility settings.
18 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml'));
19
20 // A custom block with visibility settings that contain a non-existing context
21 // mapping.
22 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml'));
23
24 foreach ($block_configs as $block_config) {
25   $connection->insert('config')
26     ->fields([
27       'collection',
28       'name',
29       'data',
30     ])
31     ->values([
32       'collection' => '',
33       'name' => 'block.block.' . $block_config['id'],
34       'data' => serialize($block_config),
35     ])
36     ->execute();
37 }
38
39 // Update the config entity query "index".
40 $existing_blocks = $connection->select('key_value')
41   ->fields('key_value', ['value'])
42   ->condition('collection', 'config.entity.key_store.block')
43   ->condition('name', 'theme:bartik')
44   ->execute()
45   ->fetchField();
46 $existing_blocks = unserialize($existing_blocks);
47
48 $connection->update('key_value')
49   ->fields([
50     'value' => serialize(array_merge($existing_blocks, ['block.block.testfor2354889', 'block.block.secondtestfor2354889', 'block.block.thirdtestfor2354889'])),
51   ])
52   ->condition('collection', 'config.entity.key_store.block')
53   ->condition('name', 'theme:bartik')
54   ->execute();