cd593723c9f984e65f1aad0be74fcd5fe22f9d47
[yaffs-website] / web / core / modules / system / tests / fixtures / update / drupal-8.site-branding-into-block-2005546.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/2005546.
7  */
8
9 use Drupal\Core\Database\Database;
10 use Drupal\Core\Serialization\Yaml;
11
12 $connection = Database::getConnection();
13
14 // Structure of a custom block with visibility settings.
15 $block_configs[] = Yaml::decode(file_get_contents(__DIR__ . '/block.block.testfor2005546.yml'));
16
17 foreach ($block_configs as $block_config) {
18   $connection->insert('config')
19     ->fields([
20       'collection',
21       'name',
22       'data',
23     ])
24     ->values([
25       'collection' => '',
26       'name' => 'block.block.' . $block_config['id'],
27       'data' => serialize($block_config),
28     ])
29     ->execute();
30 }
31
32 // Update the config entity query "index".
33 $existing_blocks = $connection->select('key_value')
34   ->fields('key_value', ['value'])
35   ->condition('collection', 'config.entity.key_store.block')
36   ->condition('name', 'theme:bartik')
37   ->execute()
38   ->fetchField();
39 $existing_blocks = unserialize($existing_blocks);
40
41 $connection->update('key_value')
42   ->fields([
43     'value' => serialize(array_merge($existing_blocks, ['block.block.bartik_branding']))
44   ])
45   ->condition('collection', 'config.entity.key_store.block')
46   ->condition('name', 'theme:bartik')
47   ->execute();
48
49 // Enable test theme.
50 $extensions = $connection->select('config')
51   ->fields('config', ['data'])
52   ->condition('name', 'core.extension')
53   ->execute()
54   ->fetchField();
55 $extensions = unserialize($extensions);
56 $connection->update('config')
57   ->fields([
58     'data' => serialize(array_merge_recursive($extensions, ['theme' => ['test_theme' => 0]]))
59   ])
60   ->condition('name', 'core.extension')
61   ->execute();