Skip to content

Commit

Permalink
Issue #3039296 by jungle, abhisekmazumdar, pandaski, tvb, dww, alexpo…
Browse files Browse the repository at this point in the history
…tt, init90: Fix examples in hook_install() and hook_uninstall()

(cherry picked from commit 0bcbf2f0093092761dcaa464752b53f3175a6173)
  • Loading branch information
catch committed Apr 23, 2020
1 parent 3042990 commit 66413ed
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions lib/Drupal/Core/Extension/module.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

use Drupal\Core\Database\Database;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Utility\UpdateException;
Expand Down Expand Up @@ -241,13 +240,8 @@ function hook_modules_installed($modules, $is_syncing) {
* @see hook_modules_installed()
*/
function hook_install($is_syncing) {
// Create the styles directory and ensure it's writable.
$directory = \Drupal::config('system.file')->get('default_scheme') . '://styles';
\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
if (!$is_syncing) {
// Modify a configuration value because we're not syncing.
\Drupal::configFactory()->getEditable('system.file')->set('default_scheme', 'private')->save();
}
// Set general module variables.
\Drupal::state()->set('mymodule.foo', 'bar');
}

/**
Expand Down Expand Up @@ -316,11 +310,8 @@ function hook_modules_uninstalled($modules, $is_syncing) {
* @see hook_modules_uninstalled()
*/
function hook_uninstall($is_syncing) {
// Remove the styles directory and generated images.
\Drupal::service('file_system')->deleteRecursive(\Drupal::config('system.file')->get('default_scheme') . '://styles');
if (!$is_syncing) {
\Drupal::service('mymodule.service')->removeContent();
}
// Delete remaining general module variables.
\Drupal::state()->delete('mymodule.foo');
}

/**
Expand Down

0 comments on commit 66413ed

Please sign in to comment.