Commit bda5391e authored by catch's avatar catch
Browse files

Issue #3039296 by jungle, abhisekmazumdar, pandaski, tvb, dww, alexpott,...

Issue #3039296 by jungle, abhisekmazumdar, pandaski, tvb, dww, alexpott, init90: Fix examples in hook_install() and hook_uninstall()

(cherry picked from commit 0bcbf2f0)
parent c8a95613
......@@ -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;
......@@ -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');
}
/**
......@@ -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');
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment