comparison core/modules/comment/comment.post_update.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children af1871eacc83
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /**
4 * @file
5 * Post update functions for the comment module.
6 */
7
8 use Drupal\Core\Config\FileStorage;
9 use Drupal\Core\Config\InstallStorage;
10
11 /**
12 * Enable the comment admin view.
13 */
14 function comment_post_update_enable_comment_admin_view() {
15 $module_handler = \Drupal::moduleHandler();
16 $entity_type_manager = \Drupal::entityTypeManager();
17
18 // Save the comment delete action to config.
19 $config_install_path = $module_handler->getModule('comment')->getPath() . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY;
20 $storage = new FileStorage($config_install_path);
21 $entity_type_manager
22 ->getStorage('action')
23 ->create($storage->read('system.action.comment_delete_action'))
24 ->save();
25
26 // Only create if the views module is enabled.
27 if (!$module_handler->moduleExists('views')) {
28 return;
29 }
30
31 // Save the comment admin view to config.
32 $optional_install_path = $module_handler->getModule('comment')->getPath() . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
33 $storage = new FileStorage($optional_install_path);
34 $entity_type_manager
35 ->getStorage('view')
36 ->create($storage->read('views.view.comment'))
37 ->save();
38 }