Version 1
[yaffs-website] / web / core / modules / system / tests / fixtures / update / drupal-8.update-test-block-disabled-2513534.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/2513534.
7  */
8
9 use Drupal\Component\Serialization\Yaml;
10 use Drupal\Core\Database\Database;
11
12 $connection = Database::getConnection();
13
14 // A disabled block.
15 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2513534.yml'));
16
17 // A block placed in the default region.
18 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.secondtestfor2513534.yml'));
19
20 foreach ($block_configs as $block_config) {
21   $connection->insert('config')
22     ->fields([
23       'collection',
24       'name',
25       'data',
26     ])
27     ->values([
28       'collection' => '',
29       'name' => 'block.block.' . $block_config['id'],
30       'data' => serialize($block_config),
31     ])
32     ->execute();
33 }
34
35 // Update the config entity query "index".
36 $existing_blocks = $connection->select('key_value')
37   ->fields('key_value', ['value'])
38   ->condition('collection', 'config.entity.key_store.block')
39   ->condition('name', 'theme:bartik')
40   ->execute()
41   ->fetchField();
42 $existing_blocks = unserialize($existing_blocks);
43
44 $connection->update('key_value')
45   ->fields([
46     'value' => serialize(array_merge($existing_blocks, ['block.block.testfor2513534', 'block.block.secondtestfor2513534']))
47   ])
48   ->condition('collection', 'config.entity.key_store.block')
49   ->condition('name', 'theme:bartik')
50   ->execute();