annotate core/modules/comment/comment.post_update.php @ 0:c75dbcec494b

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