0a9e0234d0e3bdd2a5257a41ec46ea4fe1502c9b
[yaffs-website] / web / modules / contrib / entity_browser / tests / fixtures / update / entity_browser.update-hook-test.php
1 <?php
2
3 use Drupal\Core\Database\Database;
4 use Drupal\Component\Serialization\Yaml;
5
6 $connection = Database::getConnection();
7
8 // Set the schema version.
9 $connection->merge('key_value')
10   ->condition('collection', 'system.schema')
11   ->condition('name', 'entity_embed')
12   ->fields([
13     'collection' => 'system.schema',
14     'name' => 'entity_browser',
15     'value' => 's:4:"8000";',
16   ])
17   ->execute();
18
19 $config = [
20   'uuid' => '301adade-1c60-4b90-82dd-aa588307bc62',
21   'langcode' => 'und',
22   'status' => TRUE,
23   'name' => 'test_update',
24   'label' => 'Test update hook',
25   'display' => 'iframe',
26   'display_configuration' => [],
27   'selection_display' => 'no_display',
28   'selection_display_configuration' => [],
29   'widget_selector' => 'tabs',
30   'widget_selector_configuration' => [],
31   'widgets' => [
32     'a4ad947c-9669-497c-9988-24351955a02f' => [
33       'uuid' => 'a4ad947c-9669-497c-9988-24351955a02f',
34       'settings' => [
35         'upload_location' => 'public://',
36       ],
37       'weight' => 0,
38       'label' => 'Upload files',
39       'id' => 'upload',
40     ],
41   ],
42   'submit_text' => 'All animals are created equal',
43 ];
44 $connection->insert('config')
45   ->fields([
46     'collection',
47     'name',
48     'data',
49   ])
50   ->values([
51     'collection' => '',
52     'name' => 'entity_browser.browser.test_update',
53     'data' => serialize($config),
54   ])
55   ->execute();
56
57 $config = Yaml::decode(file_get_contents(__DIR__ . '/../../modules/entity_browser_test/config/install/views.view.test_deprecated_field.yml'));
58 $connection->insert('config')
59   ->fields([
60     'collection',
61     'name',
62     'data',
63   ])
64   ->values([
65     'collection' => '',
66     'name' => 'views.view.test_deprecated_field',
67     'data' => serialize($config),
68   ])
69   ->execute();
70
71 // Update core.extension.
72 $extensions = $connection->select('config')
73   ->fields('config', ['data'])
74   ->condition('collection', '')
75   ->condition('name', 'core.extension')
76   ->execute()
77   ->fetchField();
78 $extensions = unserialize($extensions);
79 $extensions['module']['entity_browser'] = 8000;
80 $connection->update('config')
81   ->fields([
82     'data' => serialize($extensions),
83   ])
84   ->condition('collection', '')
85   ->condition('name', 'core.extension')
86   ->execute();