5 * Contains database additions to drupal-8.bare.standard.php.gz for testing the
6 * upgrade path of https://www.drupal.org/node/2354889.
9 use Drupal\Core\Database\Database;
10 use Drupal\Core\Serialization\Yaml;
12 $connection = Database::getConnection();
14 // A custom block with visibility settings.
15 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2354889.yml'));
17 // A custom block without any visibility settings.
18 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2354889.yml'));
20 // A custom block with visibility settings that contain a non-existing context
22 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.thirdtestfor2354889.yml'));
24 foreach ($block_configs as $block_config) {
25 $connection->insert('config')
33 'name' => 'block.block.' . $block_config['id'],
34 'data' => serialize($block_config),
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')
46 $existing_blocks = unserialize($existing_blocks);
48 $connection->update('key_value')
50 'value' => serialize(array_merge($existing_blocks, ['block.block.testfor2354889', 'block.block.secondtestfor2354889', 'block.block.thirdtestfor2354889'])),
52 ->condition('collection', 'config.entity.key_store.block')
53 ->condition('name', 'theme:bartik')