Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / dblog / dblog.post_update.php
1 <?php
2
3 /**
4  * @file
5  * Post update functions for the Database Logging module.
6  */
7
8 use Drupal\Core\Config\FileStorage;
9 use Drupal\Core\Config\InstallStorage;
10 use Drupal\views\Entity\View;
11
12 /**
13  * Replace 'Recent log messages' with a view.
14  */
15 function dblog_post_update_convert_recent_messages_to_view() {
16   // Only create if the views module is enabled and the watchdog view doesn't
17   // exist.
18   if (\Drupal::moduleHandler()->moduleExists('views')) {
19     if (!View::load('watchdog')) {
20       // Save the watchdog view to config.
21       $module_handler = \Drupal::moduleHandler();
22       $optional_install_path = $module_handler->getModule('dblog')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
23       $storage = new FileStorage($optional_install_path);
24
25       \Drupal::entityTypeManager()
26         ->getStorage('view')
27         ->create($storage->read('views.view.watchdog'))
28         ->save();
29
30       return t('The watchdog view has been created.');
31     }
32
33     return t("The watchdog view already exists and was not replaced. To replace the 'Recent log messages' with a view, rename the watchdog view and uninstall and install the 'Database Log' module");
34   }
35 }